[dPcommits] SF.net SVN: dotproject: [5585] branches/stable_2/dotproject
merlinyoda at users.sourceforge.net
merlinyoda at users.sourceforge.net
Thu Dec 20 10:38:33 EST 2007
Revision: 5585
http://dotproject.svn.sourceforge.net/dotproject/?rev=5585&view=rev
Author: merlinyoda
Date: 2007-12-19 15:38:33 -0800 (Wed, 19 Dec 2007)
Log Message:
-----------
Merged branches/stable_2_experimental changes r5563:5584 into branches/stable_2.
Modified Paths:
--------------
branches/stable_2/dotproject/classes/dp.class.php
branches/stable_2/dotproject/classes/query.class.php
branches/stable_2/dotproject/classes/ui.class.php
branches/stable_2/dotproject/db/upgrade_latest.php
branches/stable_2/dotproject/db/upgrade_permissions.php
branches/stable_2/dotproject/includes/permissions.php
branches/stable_2/dotproject/modules/admin/vw_usr_perms.php
branches/stable_2/dotproject/modules/calendar/calendar.class.php
branches/stable_2/dotproject/modules/companies/index.php
branches/stable_2/dotproject/modules/contacts/csvexport.php
branches/stable_2/dotproject/modules/contacts/vcardexport.php
branches/stable_2/dotproject/modules/contacts/vcardimport.php
branches/stable_2/dotproject/modules/contacts/view.php
branches/stable_2/dotproject/modules/departments/addedit.php
branches/stable_2/dotproject/modules/departments/index.php
branches/stable_2/dotproject/modules/departments/view.php
branches/stable_2/dotproject/modules/files/addedit.php
branches/stable_2/dotproject/modules/files/addedit_folder.php
branches/stable_2/dotproject/modules/files/do_file_aed.php
branches/stable_2/dotproject/modules/files/do_files_bulk_aed.php
branches/stable_2/dotproject/modules/files/files.class.php
branches/stable_2/dotproject/modules/files/folders_table.php
branches/stable_2/dotproject/modules/files/functions.php
branches/stable_2/dotproject/modules/files/index.php
branches/stable_2/dotproject/modules/files/index_table.php
branches/stable_2/dotproject/modules/files/tasks_tab.files.php
branches/stable_2/dotproject/modules/files/tasks_tab.view.files.php
branches/stable_2/dotproject/modules/forums/addedit.php
branches/stable_2/dotproject/modules/forums/configure.php
branches/stable_2/dotproject/modules/forums/index.php
branches/stable_2/dotproject/modules/forums/viewer.php
branches/stable_2/dotproject/modules/links/tasks_tab.links.php
branches/stable_2/dotproject/modules/public/selector.php
branches/stable_2/dotproject/modules/resources/view.php
branches/stable_2/dotproject/modules/system/contacts_ldap.php
branches/stable_2/dotproject/modules/system/viewmods.php
branches/stable_2/dotproject/modules/tasks/index.php
branches/stable_2/dotproject/modules/tasks/tasks.class.php
branches/stable_2/dotproject/modules/tasks/tasks.php
branches/stable_2/dotproject/modules/tasks/view.php
branches/stable_2/dotproject/style/classic/header.php
branches/stable_2/dotproject/style/default/overrides.php
Modified: branches/stable_2/dotproject/classes/dp.class.php
===================================================================
--- branches/stable_2/dotproject/classes/dp.class.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/classes/dp.class.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -286,7 +286,7 @@
* Can be overloaded/supplemented by the child class
* @return null|string null if successful otherwise returns and error message
*/
- function delete( $oid=null ) {
+ function delete( $oid=null, $history_desc = '', $history_proj = 0) {
$k = $this->_tbl_key;
if ($oid) {
$this->$k = intval( $oid );
@@ -301,7 +301,7 @@
$result = ((!$q->exec())?db_error():null);
if (!$result) {
// only record history if deletion actually occurred
- addHistory($this->_tbl, $this->$k, 'delete');
+ addHistory($this->_tbl, $this->$k, 'delete', $history_desc, $history_proj);
}
$q->clear();
return $result;
Modified: branches/stable_2/dotproject/classes/query.class.php
===================================================================
--- branches/stable_2/dotproject/classes/query.class.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/classes/query.class.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -41,657 +41,604 @@
* @copyright (c) 2003 Adam Donnison
*/
class DBQuery {
- var $query;
- var $table_list;
- var $where;
- var $order_by;
- var $group_by;
- var $limit;
- var $offset;
- var $join;
- var $type;
- var $update_list;
- var $value_list;
- var $create_table;
- var $create_definition;
- var $include_count;
- var $_table_prefix;
+ var $query;
+ var $table_list;
+ var $where;
+ var $order_by;
+ var $group_by;
+ var $limit;
+ var $offset;
+ var $join;
+ var $type;
+ var $update_list;
+ var $value_list;
+ var $create_table;
+ var $create_definition;
+ var $include_count;
+ var $_table_prefix;
var $_query_id = null;
var $_old_style = null;
-
- function DBQuery($prefix = null)
- {
- if (isset($prefix))
- $this->_table_prefix = $prefix;
- else
- $this->_table_prefix = dPgetConfig('dbprefix', '');
-
- $this->include_count = false;
- $this->clear();
- }
-
-
- function clear()
- {
+
+ function DBQuery($prefix = null) {
+ $this->_table_prefix = ((isset($prefix)) ? $prefix : dPgetConfig('dbprefix', ''));
+ $this->include_count = false;
+ $this->clear();
+ }
+
+
+ function clear() {
global $ADODB_FETCH_MODE;
if (isset($this->_old_style)) {
$ADODB_FETCH_MODE = $this->_old_style;
$this->_old_style = null;
}
- $this->type = 'select';
- $this->query = null;
- $this->table_list = null;
- $this->where = null;
- $this->order_by = null;
- $this->group_by = null;
- $this->limit = null;
- $this->offset = -1;
- $this->join = null;
- $this->value_list = null;
- $this->update_list = null;
- $this->create_table = null;
- $this->create_definition = null;
- if ($this->_query_id)
+ $this->type = 'select';
+ $this->query = null;
+ $this->table_list = null;
+ $this->where = null;
+ $this->order_by = null;
+ $this->group_by = null;
+ $this->limit = null;
+ $this->offset = -1;
+ $this->join = null;
+ $this->value_list = null;
+ $this->update_list = null;
+ $this->create_table = null;
+ $this->create_definition = null;
+ if ($this->_query_id) {
$this->_query_id->Close();
+ }
$this->_query_id = null;
- }
+ }
- function clearQuery()
- {
- if ($this->_query_id)
+ function clearQuery() {
+ if ($this->_query_id) {
$this->_query_id->Close();
+ }
$this->_query_id = null;
}
-
- /**
- * Add a hash item to an array.
- *
- * @access private
- * @param string $varname Name of variable to add/create
- * @param mixed $name Data to add
- * @param string $id Index to use in array.
- */
- function addMap($varname, $name, $id)
- {
- if (!isset($this->$varname))
- $this->$varname = array();
- if (isset($id))
- $this->{$varname}[$id] = $name;
- else
- $this->{$varname}[] = $name;
- }
-
- /**
- * Adds a table to the query. A table is normally addressed by an
- * alias. If you don't supply the alias chances are your code will
- * break. You can add as many tables as are needed for the query.
- * E.g. addTable('something', 'a') will result in an SQL statement
- * of {PREFIX}table as a.
- * Where {PREFIX} is the system defined table prefix.
- *
- * @param string $name Name of table, without prefix.
- * @parem string $id Alias for use in query/where/group clauses.
- */
- function addTable($name, $id = null)
- {
- $this->addMap('table_list', $name, $id);
- }
-
- /**
- * Add a clause to an array. Checks to see variable exists first.
- * then pushes the new data onto the end of the array.
- */
- function addClause($clause, $value, $check_array = true)
- {
- dprint(__FILE__, __LINE__, 8, "Adding '$value' to $clause clause");
- if (!isset($this->$clause))
- $this->$clause = array();
- if ($check_array && is_array($value)) {
- foreach ($value as $v) {
- array_push($this->$clause, $v);
- }
- } else {
- array_push($this->$clause, $value);
- }
- }
-
- /**
- * Add the actual select part of the query. E.g. '*', or 'a.*'
- * or 'a.field, b.field', etc. You can call this multiple times
- * and it will correctly format a combined query.
- *
- * @param string $query Query string to use.
- */
- function addQuery($query)
- {
- $this->addClause('query', $query);
- }
-
- function addInsert($field, $value, $set = false, $func = false)
- {
- if ($set)
- {
- if (is_array($field))
- $fields = $field;
- else
- $fields = explode(',', $field);
-
- if (is_array($value))
- $values = $value;
- else
- $values = explode(',', $value);
-
- for($i = 0; $i < count($fields); $i++)
+
+ /**
+ * Add a hash item to an array.
+ *
+ * @access private
+ * @param string $varname Name of variable to add/create
+ * @param mixed $name Data to add
+ * @param string $id Index to use in array.
+ */
+ function addMap($varname, $name, $id) {
+ if (!isset($this->$varname)) {
+ $this->$varname = array();
+ }
+
+ if (isset($id)) {
+ $this->{$varname}[$id] = $name;
+ } else {
+ $this->{$varname}[] = $name;
+ }
+ }
+
+ /**
+ * Adds a table to the query. A table is normally addressed by an
+ * alias. If you don't supply the alias chances are your code will
+ * break. You can add as many tables as are needed for the query.
+ * E.g. addTable('something', 'a') will result in an SQL statement
+ * of {PREFIX}table as a.
+ * Where {PREFIX} is the system defined table prefix.
+ *
+ * @param string $name Name of table, without prefix.
+ * @parem string $id Alias for use in query/where/group clauses.
+ */
+ function addTable($name, $id = null) {
+ $this->addMap('table_list', $name, $id);
+ }
+
+ /**
+ * Add a clause to an array. Checks to see variable exists first.
+ * then pushes the new data onto the end of the array.
+ */
+ function addClause($clause, $value, $check_array = true) {
+ dprint(__FILE__, __LINE__, 8, "Adding '$value' to $clause clause");
+ if (!isset($this->$clause)) {
+ $this->$clause = array();
+ }
+ if ($check_array && is_array($value)) {
+ foreach ($value as $v) {
+ array_push($this->$clause, $v);
+ }
+ } else {
+ array_push($this->$clause, $value);
+ }
+ }
+
+ /**
+ * Add the actual select part of the query. E.g. '*', or 'a.*'
+ * or 'a.field, b.field', etc. You can call this multiple times
+ * and it will correctly format a combined query.
+ *
+ * @param string $query Query string to use.
+ */
+ function addQuery($query) {
+ $this->addClause('query', $query);
+ }
+
+ function addInsert($field, $value, $set = false, $func = false) {
+ if ($set) {
+ $fields = ((is_array($field)) ? $field : explode(',', $field));
+ $values = ((is_array($value)) ? $value : explode(',', $value));
+
+ for($i = 0; $i < count($fields); $i++) {
$this->addMap('value_list', $this->quote($values[$i]), $fields[$i]);
+ }
+ } else if (!$func) {
+ $this->addMap('value_list', $this->quote($value), $field);
+ } else {
+ $this->addMap('value_list', $value, $field);
}
- else if (!$func)
- $this->addMap('value_list', $this->quote($value), $field);
- else
- $this->addMap('value_list', $value, $field);
- $this->type = 'insert';
- }
-
- // implemented addReplace() on top of addInsert()
-
- function addReplace($field, $value, $set = false, $func = false)
- {
- $this->addInsert($field, $value, $set, $func);
- $this->type = 'replace';
- }
+ $this->type = 'insert';
+ }
+
+ // implemented addReplace() on top of addInsert()
+
+ function addReplace($field, $value, $set = false, $func = false) {
+ $this->addInsert($field, $value, $set, $func);
+ $this->type = 'replace';
+ }
+
+
+ function addUpdate($field, $value, $set = false) {
+ if ($set) {
+ $fields = ((is_array($field)) ? $field : explode(',', $field));
+ $values = ((is_array($value)) ? $value : explode(',', $value));
-
- function addUpdate($field, $value, $set = false)
- {
- if ($set)
- {
- if (is_array($field))
- $fields = $field;
- else
- $fields = explode(',', $field);
-
- if (is_array($value))
- $values = $value;
- else
- $values = explode(',', $value);
-
- for($i = 0; $i < count($fields); $i++)
+ for($i = 0; $i < count($fields); $i++) {
$this->addMap('update_list', $values[$i], $fields[$i]);
- }
- else
+ }
+ } else {
$this->addMap('update_list', $value, $field);
- $this->type = 'update';
- }
-
- function createTable($table)
- {
- $this->type = 'createPermanent';
- $this->create_table = $table;
- }
-
- function createTemp($table)
- {
- $this->type = 'create';
- $this->create_table = $table;
- }
-
- function dropTable($table)
- {
- $this->type = 'drop';
- $this->create_table = $table;
- }
-
- function dropTemp($table)
- {
- $this->type = 'drop';
- $this->create_table = $table;
- }
-
- function alterTable($table)
- {
+ }
+ $this->type = 'update';
+ }
+
+ function createTable($table) {
+ $this->type = 'createPermanent';
$this->create_table = $table;
+ }
+
+ function createTemp($table) {
+ $this->type = 'create';
+ $this->create_table = $table;
+ }
+
+ function dropTable($table) {
+ $this->type = 'drop';
+ $this->create_table = $table;
+ }
+
+ function dropTemp($table) {
+ $this->type = 'drop';
+ $this->create_table = $table;
+ }
+
+ function alterTable($table) {
+ $this->create_table = $table;
$this->type = 'alter';
}
-
- function addField($name, $type)
- {
+
+ function addField($name, $type) {
if (! is_array($this->create_definition))
$this->create_definition = array();
$this->create_definition[] = array('action' => 'ADD',
'type' => '',
'spec' => $name . ' ' . $type);
}
-
- function alterField($name, $type)
- {
- if (! is_array($this->create_definition))
+
+ function alterField($name, $type) {
+ if (! is_array($this->create_definition)) {
$this->create_definition = array();
+ }
$this->create_definition[] = array('action' => 'CHANGE',
- 'type' => '',
- 'spec' => $name . ' ' . $name . ' ' . $type);
+ 'type' => '',
+ 'spec' => $name . ' ' . $name . ' ' . $type);
}
-
- function dropField($name)
- {
- if (! is_array($this->create_definition))
+
+ function dropField($name) {
+ if (! is_array($this->create_definition)) {
$this->create_definition = array();
+ }
$this->create_definition[] = array('action' => 'DROP',
- 'type' => '',
- 'spec' => $name);
+ 'type' => '',
+ 'spec' => $name);
}
-
- function addIndex($name, $type)
- {
- if (! is_array($this->create_definition))
+
+ function addIndex($name, $type) {
+ if (! is_array($this->create_definition)) {
$this->create_definition = array();
+ }
$this->create_definition[] = array('action' => 'ADD',
- 'type' => 'INDEX',
- 'spec' => $name . ' ' . $type);
+ 'type' => 'INDEX',
+ 'spec' => $name . ' ' . $type);
}
-
- function dropIndex($name)
- {
- if (! is_array($this->create_definition))
+
+ function dropIndex($name) {
+ if (! is_array($this->create_definition)) {
$this->create_definition = array();
+ }
$this->create_definition[] = array('action' => 'DROP',
- 'type' => 'INDEX',
- 'spec' => $name);
+ 'type' => 'INDEX',
+ 'spec' => $name);
}
-
- function dropPrimary()
- {
- if (! is_array($this->create_definition))
+
+ function dropPrimary() {
+ if (! is_array($this->create_definition)) {
$this->create_definition = array();
+ }
$this->create_definition[] = array('action' => 'DROP',
- 'type' => 'PRIMARY KEY',
- 'spec' => '');
+ 'type' => 'PRIMARY KEY',
+ 'spec' => '');
}
-
- function createDefinition($def)
- {
- $this->create_definition = $def;
- }
-
- function setDelete($table)
- {
+
+ function createDefinition($def) {
+ $this->create_definition = $def;
+ }
+
+ function setDelete($table) {
$this->type = 'delete';
$this->addMap('table_list', $table, null);
}
+
+ /**
+ * Add where sub-clauses. The where clause can be built up one
+ * part at a time and the resultant query will put in the 'and'
+ * between each component.
+ *
+ * Make sure you use table aliases.
+ *
+ * @param string $query Where subclause to use
+ */
+ function addWhere($query) {
+ if (isset($query)) {
+ $this->addClause('where', $query);
+ }
+ }
+
+ /**
+ * Add a join condition to the query. This only implements
+ * left join, however most other joins are either synonymns or
+ * can be emulated with where clauses.
+ *
+ * @param string $table Name of table (without prefix)
+ * @param string $alias Alias to use instead of table name (required).
+ * @param mixed $join Join condition (e.g. 'a.id = b.other_id')
+ * or array of join fieldnames, e.g. array('id', 'name);
+ * Both are correctly converted into a join clause.
+ */
+ function addJoin($table, $alias, $join, $type = 'left') {
+ $var = array ('table' => $table,
+ 'alias' => $alias,
+ 'condition' => $join,
+ 'type' => $type );
+
+ $this->addClause('join', $var, false);
+ }
+
+ function leftJoin($table, $alias, $join) {
+ $this->addJoin($table, $alias, $join, 'left');
+ }
+
+ function rightJoin($table, $alias, $join) {
+ $this->addJoin($table, $alias, $join, 'right');
+ }
+
+ function innerJoin($table, $alias, $join) {
+ $this->addJoin($table, $alias, $join, 'inner');
+ }
+
+ /**
+ * Add an order by clause. Again, only the fieldname is required, and
+ * it should include an alias if a table has been added.
+ * May be called multiple times.
+ *
+ * @param string $order Order by field.
+ */
+ function addOrder($order) {
+ if (isset($order)) {
+ $this->addClause('order_by', $order);
+ }
+ }
+
+ /**
+ * Add a group by clause. Only the fieldname is required.
+ * May be called multiple times. Use table aliases as required.
+ *
+ * @param string $group Field name to group by.
+ */
+ function addGroup($group) {
+ $this->addClause('group_by', $group);
+ }
- /**
- * Add where sub-clauses. The where clause can be built up one
- * part at a time and the resultant query will put in the 'and'
- * between each component.
- *
- * Make sure you use table aliases.
- *
- * @param string $query Where subclause to use
- */
- function addWhere($query)
- {
- if (isset($query))
- $this->addClause('where', $query);
- }
-
- /**
- * Add a join condition to the query. This only implements
- * left join, however most other joins are either synonymns or
- * can be emulated with where clauses.
- *
- * @param string $table Name of table (without prefix)
- * @param string $alias Alias to use instead of table name (required).
- * @param mixed $join Join condition (e.g. 'a.id = b.other_id')
- * or array of join fieldnames, e.g. array('id', 'name);
- * Both are correctly converted into a join clause.
- */
- function addJoin($table, $alias, $join, $type = 'left')
- {
- $var = array ( 'table' => $table,
- 'alias' => $alias,
- 'condition' => $join,
- 'type' => $type );
-
- $this->addClause('join', $var, false);
- }
-
- function leftJoin($table, $alias, $join)
- {
- $this->addJoin($table, $alias, $join, 'left');
- }
-
- function rightJoin($table, $alias, $join)
- {
- $this->addJoin($table, $alias, $join, 'right');
- }
-
- function innerJoin($table, $alias, $join)
- {
- $this->addJoin($table, $alias, $join, 'inner');
- }
-
- /**
- * Add an order by clause. Again, only the fieldname is required, and
- * it should include an alias if a table has been added.
- * May be called multiple times.
- *
- * @param string $order Order by field.
- */
- function addOrder($order)
- {
- if (isset($order))
- $this->addClause('order_by', $order);
- }
-
- /**
- * Add a group by clause. Only the fieldname is required.
- * May be called multiple times. Use table aliases as required.
- *
- * @param string $group Field name to group by.
- */
- function addGroup($group)
- {
- $this->addClause('group_by', $group);
- }
-
- /**
- * Set a limit on the query. This is done in a database-independent
- * fashion.
- *
- * @param integer $limit Number of rows to limit.
- * @param integer $start First row to start extraction.
- */
- function setLimit($limit, $start = -1)
- {
- $this->limit = $limit;
- $this->offset = $start;
- }
-
- /**
- * Set include count feature, grabs the count of rows that
- * would have been returned had no limit been set.
- */
- function includeCount()
- {
- $this->include_count = true;
- }
-
- /**
- * Prepare a query for execution via db_exec.
- *
- */
- function prepare($clear = false)
- {
- switch ($this->type) {
- case 'select':
- $q = $this->prepareSelect();
- break;
- case 'update':
- $q = $this->prepareUpdate();
- break;
- case 'insert':
- $q = $this->prepareInsert();
- break;
- case 'replace':
- $q = $this->prepareReplace();
- break;
- case 'delete':
- $q = $this->prepareDelete();
- break;
- case 'create': // Create a temporary table
- $s = $this->prepareSelect();
- $q = 'CREATE TEMPORARY TABLE ' . $this->_table_prefix . $this->create_table;
- if (!empty($this->create_definition))
- $q .= ' ' . $this->create_definition;
- $q .= ' ' . $s;
- break;
- case 'alter':
- $q = $this->prepareAlter();
- break;
- case 'createPermanent': // Create a temporary table
- $s = $this->prepareSelect();
- $q = 'CREATE TABLE ' . $this->_table_prefix . $this->create_table;
- if (!empty($this->create_definition))
- $q .= ' ' . $this->create_definition;
- $q .= ' ' . $s;
- break;
- case 'drop':
- $q = 'DROP TABLE IF EXISTS ' . $this->_table_prefix . $this->create_table;
- break;
- }
- if ($clear)
+ /**
+ * Set a limit on the query. This is done in a database-independent
+ * fashion.
+ *
+ * @param integer $limit Number of rows to limit.
+ * @param integer $start First row to start extraction.
+ */
+ function setLimit($limit, $start = -1) {
+ $this->limit = $limit;
+ $this->offset = $start;
+ }
+
+ /**
+ * Set include count feature, grabs the count of rows that
+ * would have been returned had no limit been set.
+ */
+ function includeCount() {
+ $this->include_count = true;
+ }
+
+ /**
+ * Prepare a query for execution via db_exec.
+ *
+ */
+ function prepare($clear = false) {
+ switch ($this->type) {
+ case 'select':
+ $q = $this->prepareSelect();
+ break;
+ case 'update':
+ $q = $this->prepareUpdate();
+ break;
+ case 'insert':
+ $q = $this->prepareInsert();
+ break;
+ case 'replace':
+ $q = $this->prepareReplace();
+ break;
+ case 'delete':
+ $q = $this->prepareDelete();
+ break;
+ case 'create': // Create a temporary table
+ $s = $this->prepareSelect();
+ $q = 'CREATE TEMPORARY TABLE ' . $this->_table_prefix . $this->create_table;
+ if (!empty($this->create_definition)) {
+ $q .= ' ' . $this->create_definition;
+ }
+ $q .= ' ' . $s;
+ break;
+ case 'alter':
+ $q = $this->prepareAlter();
+ break;
+ case 'createPermanent': // Create a temporary table
+ $s = $this->prepareSelect();
+ $q = 'CREATE TABLE ' . $this->_table_prefix . $this->create_table;
+ if (!empty($this->create_definition)) {
+ $q .= ' ' . $this->create_definition;
+ }
+ $q .= ' ' . $s;
+ break;
+ case 'drop':
+ $q = 'DROP TABLE IF EXISTS ' . $this->_table_prefix . $this->create_table;
+ break;
+ }
+ if ($clear) {
$this->clear();
- return $q;
- dprint(__FILE__, __LINE__, 2, $q);
- }
-
- function prepareSelect()
- {
- $q = 'SELECT ';
- if ($this->include_count) {
- $q .= 'SQL_CALC_FOUND_ROWS ';
- }
- if (isset($this->query)) {
- if (is_array($this->query)) {
- $inselect = false;
- $q .= implode(',', $this->query);
- } else {
- $q .= $this->query;
- }
- } else {
- $q .= '*';
- }
- $q .= ' FROM ';
- if (isset($this->table_list)) {
- if (is_array($this->table_list)) {
- $q .= '( '; // Required for MySQL 5 compatability.
- $intable = false;
- foreach ($this->table_list as $table_id => $table) {
- if ($intable)
- $q .= ",";
- else
- $intable = true;
- $q .= '`' . $this->_table_prefix . $table . '`';
- if (! is_numeric($table_id))
- $q .= " as $table_id";
+ }
+ return $q;
+ dprint(__FILE__, __LINE__, 2, $q);
}
- $q .= ' )'; // MySQL 5 compat.
- } else {
- $q .= $this->_table_prefix . $this->table_list;
- }
- } else {
- return false;
- }
- $q .= $this->make_join($this->join);
- $q .= $this->make_where_clause($this->where);
- $q .= $this->make_group_clause($this->group_by);
- $q .= $this->make_order_clause($this->order_by);
- return $q;
- }
+
+ function prepareSelect() {
+ $q = 'SELECT ';
+ if ($this->include_count) {
+ $q .= 'SQL_CALC_FOUND_ROWS ';
+ }
+ if (isset($this->query)) {
+ if (is_array($this->query)) {
+ $inselect = false;
+ $q .= implode(',', $this->query);
+ } else {
+ $q .= $this->query;
+ }
+ } else {
+ $q .= '*';
+ }
+ $q .= ' FROM ';
+ if (isset($this->table_list)) {
+ if (is_array($this->table_list)) {
+ $q .= '( '; // Required for MySQL 5 compatability.
+ $intable = false;
+ foreach ($this->table_list as $table_id => $table) {
+ if ($intable) {
+ $q .= ",";
+ } else {
+ $intable = true;
+ }
+ $q .= '`' . $this->_table_prefix . $table . '`';
+ if (! is_numeric($table_id)) {
+ $q .= " as $table_id";
+ }
+ }
+ $q .= ' )'; // MySQL 5 compat.
+ } else {
+ $q .= $this->_table_prefix . $this->table_list;
+ }
+ } else {
+ return false;
+ }
+ $q .= $this->make_join($this->join);
+ $q .= $this->make_where_clause($this->where);
+ $q .= $this->make_group_clause($this->group_by);
+ $q .= $this->make_order_clause($this->order_by);
+ return $q;
+ }
+
+ function prepareUpdate() {
+ // You can only update one table, so we get the table detail
+ $q = 'UPDATE ';
+ if (isset($this->table_list)) {
+ if (is_array($this->table_list)) {
+ reset($this->table_list);
+ // Grab the first record
+ list($key, $table) = each ($this->table_list);
+ } else {
+ $table = $this->table_list;
+ }
+ } else {
+ return false;
+ }
+ $q .= '`' . $this->_table_prefix . $table . '`';
+
+ $q .= ' SET ';
+ $sets = '';
+ foreach( $this->update_list as $field => $value) {
+ $sets .= (($sets) ? ', ' : '') . "`$field` = " . $this->quote($value);
+ }
+ $q .= $sets;
+ $q .= $this->make_where_clause($this->where);
+ return $q;
+ }
+
+ function prepareInsert() {
+ $q = 'INSERT INTO ';
+ if (isset($this->table_list)) {
+ if (is_array($this->table_list)) {
+ reset($this->table_list);
+ // Grab the first record
+ list($key, $table) = each ($this->table_list);
+ } else {
+ $table = $this->table_list;
+ }
+ } else {
+ return false;
+ }
+ $q .= '`' . $this->_table_prefix . $table . '`';
+
+ $fieldlist = '';
+ $valuelist = '';
+ foreach( $this->value_list as $field => $value) {
+ $fieldlist .= (($fieldlist) ? ',' : '') . '`' . trim($field) . '`';
+ $valuelist .= (($valuelist) ? ',' : '') . $value;
+ }
+ $q .= "($fieldlist) values ($valuelist)";
+ return $q;
+ }
+
+ function prepareReplace() {
+ $q = 'REPLACE INTO ';
+ if (isset($this->table_list)) {
+ if (is_array($this->table_list)) {
+ reset($this->table_list);
+ // Grab the first record
+ list($key, $table) = each ($this->table_list);
+ } else {
+ $table = $this->table_list;
+ }
+ } else {
+ return false;
+ }
+ $q .= '`' . $this->_table_prefix . $table . '`';
+
+ $fieldlist = '';
+ $valuelist = '';
+
+ foreach( $this->value_list as $field => $value) {
+ $fieldlist .= (($fieldlist) ? ',' : '') . '`' . trim($field) . '`';
+ $valuelist .= (($valuelist) ? ',' : '') . $value;
+ }
+ $q .= "($fieldlist) values ($valuelist)";
+ return $q;
+ }
+
+ function prepareDelete() {
+ $q = 'DELETE FROM ';
+ if (isset($this->table_list)) {
+ if (is_array($this->table_list)) {
+ // Grab the first record
+ list($key, $table) = each ($this->table_list);
+ } else {
+ $table = $this->table_list;
+ }
+ } else {
+ return false;
+ }
+ $q .= '`' . $this->_table_prefix . $table . '`';
+ $q .= $this->make_where_clause($this->where);
+ return $q;
+ }
- function prepareUpdate()
- {
- // You can only update one table, so we get the table detail
- $q = 'UPDATE ';
- if (isset($this->table_list)) {
- if (is_array($this->table_list)) {
- reset($this->table_list);
- // Grab the first record
- list($key, $table) = each ($this->table_list);
- } else {
- $table = $this->table_list;
- }
- } else {
- return false;
- }
- $q .= '`' . $this->_table_prefix . $table . '`';
-
- $q .= ' SET ';
- $sets = '';
- foreach( $this->update_list as $field => $value) {
- if ($sets)
- $sets .= ", ";
- $sets .= "`$field` = " . $this->quote($value);
- }
- $q .= $sets;
- $q .= $this->make_where_clause($this->where);
- return $q;
- }
-
- function prepareInsert()
- {
- $q = 'INSERT INTO ';
- if (isset($this->table_list)) {
- if (is_array($this->table_list)) {
- reset($this->table_list);
- // Grab the first record
- list($key, $table) = each ($this->table_list);
- } else {
- $table = $this->table_list;
- }
- } else {
- return false;
- }
- $q .= '`' . $this->_table_prefix . $table . '`';
-
- $fieldlist = '';
- $valuelist = '';
- foreach( $this->value_list as $field => $value) {
- if ($fieldlist)
- $fieldlist .= ",";
- if ($valuelist)
- $valuelist .= ",";
- $fieldlist .= '`' . trim($field) . '`';
- $valuelist .= $value;
- }
- $q .= "($fieldlist) values ($valuelist)";
- return $q;
- }
-
- function prepareReplace()
- {
- $q = 'REPLACE INTO ';
- if (isset($this->table_list)) {
- if (is_array($this->table_list)) {
- reset($this->table_list);
- // Grab the first record
- list($key, $table) = each ($this->table_list);
- } else {
- $table = $this->table_list;
- }
- } else {
- return false;
- }
- $q .= '`' . $this->_table_prefix . $table . '`';
-
- $fieldlist = '';
- $valuelist = '';
- foreach( $this->value_list as $field => $value) {
- if ($fieldlist)
- $fieldlist .= ",";
- if ($valuelist)
- $valuelist .= ",";
- $fieldlist .= '`' . trim($field) . '`';
- $valuelist .= $value;
- }
- $q .= "($fieldlist) values ($valuelist)";
- return $q;
- }
-
- function prepareDelete()
- {
- $q = 'DELETE FROM ';
- if (isset($this->table_list)) {
- if (is_array($this->table_list)) {
- // Grab the first record
- list($key, $table) = each ($this->table_list);
- } else {
- $table = $this->table_list;
- }
- } else {
- return false;
- }
- $q .= '`' . $this->_table_prefix . $table . '`';
- $q .= $this->make_where_clause($this->where);
- return $q;
- }
-
//TODO: add ALTER DROP/CHANGE/MODIFY/IMPORT/DISCARD/...
//definitions: http://dev.mysql.com/doc/mysql/en/alter-table.html
- function prepareAlter()
- {
+ function prepareAlter() {
$q = 'ALTER TABLE `' . $this->_table_prefix . $this->create_table . '` ';
if (isset($this->create_definition)) {
- if (is_array($this->create_definition)) {
- $first = true;
- foreach ($this->create_definition as $def) {
- if ($first)
- $first = false;
- else
- $q .= ', ';
- $q .= $def['action'] . ' ' . $def['type'] . ' ' . $def['spec'];
- }
- } else {
- $q .= 'ADD ' . $this->create_definition;
- }
+ $alters = '';
+ if (is_array($this->create_definition)) {
+ foreach ($this->create_definition as $def) {
+ $alters .= ((($alters) ? ', ' : ' ') . $def['action'] . ' ' . $def['type']
+ . ' ' . $def['spec']);
+ }
+ } else {
+ $alters .= ' ADD ' . $this->create_definition;
+ }
+ $q .= $alters;
}
-
+
return $q;
}
+
+ /**
+ * Execute the query and return a handle. Supplants the db_exec query
+ */
+ function &exec($style = ADODB_FETCH_BOTH, $debug = false) {
+ global $db;
+ global $ADODB_FETCH_MODE;
+
+ if (! isset($this->_old_style)) {
+ $this->_old_style = $ADODB_FETCH_MODE;
+ }
+
+ $ADODB_FETCH_MODE = $style;
+ $this->clearQuery();
+ if ($q = $this->prepare()) {
+ dprint(__FILE__, __LINE__, 7, "executing query($q)");
+ if ($debug) {
+ // Before running the query, explain the query and return the details.
+ $qid = $db->Execute('EXPLAIN ' . $q);
+ if ($qid) {
+ $res = array();
+ while ($row = $this->fetchRow()) {
+ $res[] = $row;
+ }
+ dprint(__FILE__, __LINE__, 0, "QUERY DEBUG: " . var_export($res, true));
+ $qid->Close();
+ }
+ }
+ $this->_query_id = ((isset($this->limit))
+ ? $db->SelectLimit($q, $this->limit, $this->offset)
+ : $db->Execute($q));
+
+ if (! $this->_query_id) {
+ $error = $db->ErrorMsg();
+ dprint(__FILE__, __LINE__, 0, "query failed($q) - error was: " . $error);
+ return $this->_query_id;
+ }
+ }
+
+ return $this->_query_id;
+ }
- /**
- * Execute the query and return a handle. Supplants the db_exec query
- */
- function &exec($style = ADODB_FETCH_BOTH, $debug = false)
- {
- global $db;
- global $ADODB_FETCH_MODE;
-
- if (! isset($this->_old_style))
- $this->_old_style = $ADODB_FETCH_MODE;
- $ADODB_FETCH_MODE = $style;
- $this->clearQuery();
- if ($q = $this->prepare()) {
- dprint(__FILE__, __LINE__, 7, "executing query($q)");
- if ($debug) {
- // Before running the query, explain the query and return the details.
- $qid = $db->Execute('EXPLAIN ' . $q);
- if ($qid) {
- $res = array();
- while ($row = $this->fetchRow()) {
- $res[] = $row;
- }
- dprint(__FILE__, __LINE__, 0, "QUERY DEBUG: " . var_export($res, true));
- $qid->Close();
- }
- }
- if (isset($this->limit)) {
- $this->_query_id = $db->SelectLimit($q, $this->limit, $this->offset);
- } else {
- $this->_query_id = $db->Execute($q);
- }
- if (! $this->_query_id) {
- $error = $db->ErrorMsg();
- dprint(__FILE__, __LINE__, 0, "query failed($q) - error was: " . $error);
- return $this->_query_id;
- }
- return $this->_query_id;
- } else {
- return $this->_query_id;
- }
- }
-
- function fetchRow()
- {
+ function fetchRow() {
if (! $this->_query_id) {
return false;
}
return $this->_query_id->FetchRow();
}
-
+
/**
* loadList - replaces dbLoadList on
*/
- function loadList($maxrows = null)
- {
+ function loadList($maxrows = null) {
global $db;
global $AppUI;
@@ -705,13 +652,14 @@
$cnt = 0;
while ($hash = $this->fetchRow()) {
$list[] = $hash;
- if ($maxrows && $maxrows == $cnt++)
+ if ($maxrows && $maxrows == $cnt++) {
break;
+ }
}
$this->clear();
return $list;
}
-
+
function loadHashList($index = null) {
global $db;
@@ -726,8 +674,9 @@
} else {
// If we are using fetch mode of ASSOC, then we don't
// have an array index we can use, so we need to get one
- if (! $keys)
+ if (! $keys) {
$keys = array_keys($hash);
+ }
$hashlist[$hash[$keys[0]]] = $hash[$keys[1]];
}
}
@@ -735,8 +684,7 @@
return $hashlist;
}
- function loadHash()
- {
+ function loadHash() {
global $db;
if (! $this->exec(ADODB_FETCH_ASSOC)) {
exit ($this->db->ErrorMsg());
@@ -786,14 +734,12 @@
}
$this->bindHashToObject( $hash, $object, null, $strip, $bindAll );
return true;
+ } else if ($object = $this->_query_id->FetchNextObject(false)) {
+ $this->clear();
+ return true;
} else {
- if ($object = $this->_query_id->FetchNextObject(false)) {
- $this->clear();
- return true;
- } else {
- $object = null;
- return false;
- }
+ $object = null;
+ return false;
}
}
@@ -814,119 +760,115 @@
$AppUI->setMsg(array('Error in XML Schema', 'Error', $db->ErrorMsg()), UI_MSG_ERR);
return false;
}
- if ($schema->ExecuteSchema($sql, true))
- return true;
- else
- return false;
+
+ return (($schema->ExecuteSchema($sql, true)) ? true : false);
}
- /** {{{2 function loadResult
- * Load a single column result from a single row
- */
- function loadResult()
- {
- global $AppUI;
+ /** {{{2 function loadResult
+ * Load a single column result from a single row
+ */
+ function loadResult() {
+ global $AppUI;
+
+ $result = false;
+
+ if (! $this->exec(ADODB_FETCH_NUM)) {
+ $AppUI->setMsg($db->ErrorMsg(), UI_MSG_ERROR);
+ } else if ($data = $this->fetchRow()) {
+ $result = $data[0];
+ }
+ $this->clear();
+ return $result;
+ }
+ //2}}}
- $result = false;
-
- if (! $this->exec(ADODB_FETCH_NUM)) {
- $AppUI->setMsg($db->ErrorMsg(), UI_MSG_ERROR);
- } else if ($data = $this->fetchRow()) {
- $result = $data[0];
- }
- $this->clear();
- return $result;
- }
- //2}}}
-
- /** {{{2 function make_where_clause
- * Create a where clause based upon supplied field.
- *
- * @param mixed $clause Either string or array of subclauses.
- * @return string
- */
- function make_where_clause($where_clause)
- {
- $result = '';
- if (! isset($where_clause))
- return $result;
- if (is_array($where_clause)) {
- if (count($where_clause)) {
- $started = false;
- $result = ' WHERE ' . implode(' AND ', $where_clause);
- }
- } else if (strlen($where_clause) > 0) {
- $result = " where $where_clause";
- }
- return $result;
- }
- //2}}}
-
- /** {{{2 function make_order_clause
- * Create an order by clause based upon supplied field.
- *
- * @param mixed $clause Either string or array of subclauses.
- * @return string
- */
- function make_order_clause($order_clause)
- {
- $result = "";
- if (! isset($order_clause))
- return $result;
-
- if (is_array($order_clause)) {
- $started = false;
- $result = ' ORDER BY ' . implode(',', $order_clause);
- } else if (strlen($order_clause) > 0) {
- $result = " ORDER BY $order_clause";
- }
- return $result;
- }
- //2}}}
-
- //{{{2 function make_group_clause
- function make_group_clause($group_clause)
- {
- $result = "";
- if (! isset($group_clause))
- return $result;
-
- if (is_array($group_clause)) {
- $started = false;
- $result = ' GROUP BY ' . implode(',', $group_clause);
- } else if (strlen($group_clause) > 0) {
- $result = " GROUP BY $group_clause";
- }
- return $result;
- }
- //2}}}
-
- //{{{2 function make_join
- function make_join($join_clause)
- {
- $result = "";
- if (! isset($join_clause))
- return $result;
- if (is_array($join_clause)) {
- foreach ($join_clause as $join) {
- $result .= ' ' . strtoupper($join['type']) . ' JOIN `' . $this->_table_prefix . $join['table'] . '`';
- if ($join['alias'])
- $result .= ' AS ' . $join['alias'];
- if (is_array($join['condition'])) {
- $result .= ' USING (' . implode(',', $join['condition']) . ')';
- } else {
- $result .= ' ON ' . $join['condition'];
+ /** {{{2 function make_where_clause
+ * Create a where clause based upon supplied field.
+ *
+ * @param mixed $clause Either string or array of subclauses.
+ * @return string
+ */
+ function make_where_clause($where_clause) {
+ $result = '';
+ if (! isset($where_clause)) {
+ return $result;
+ }
+ if (is_array($where_clause)) {
+ if (count($where_clause)) {
+ $started = false;
+ $result = ' WHERE ' . implode(' AND ', $where_clause);
+ }
+ } else if (strlen($where_clause) > 0) {
+ $result = " where $where_clause";
+ }
+ return $result;
}
- }
- } else {
- $result .= ' LEFT JOIN `' . $this->_table_prefix . $join_clause . '`';
- }
- return $result;
- }
- //2}}}
+ //2}}}
+
+ /** {{{2 function make_order_clause
+ * Create an order by clause based upon supplied field.
+ *
+ * @param mixed $clause Either string or array of subclauses.
+ * @return string
+ */
+ function make_order_clause($order_clause) {
+ $result = "";
+ if (! isset($order_clause)) {
+ return $result;
+ }
- function foundRows()
- {
+ if (is_array($order_clause)) {
+ $started = false;
+ $result = ' ORDER BY ' . implode(',', $order_clause);
+ } else if (strlen($order_clause) > 0) {
+ $result = " ORDER BY $order_clause";
+ }
+ return $result;
+ }
+ //2}}}
+
+ //{{{2 function make_group_clause
+ function make_group_clause($group_clause) {
+ $result = "";
+ if (! isset($group_clause)) {
+ return $result;
+ }
+
+ if (is_array($group_clause)) {
+ $started = false;
+ $result = ' GROUP BY ' . implode(',', $group_clause);
+ } else if (strlen($group_clause) > 0) {
+ $result = " GROUP BY $group_clause";
+ }
+ return $result;
+ }
+ //2}}}
+
+ //{{{2 function make_join
+ function make_join($join_clause) {
+ $result = "";
+ if (! isset($join_clause)) {
+ return $result;
+ }
+ if (is_array($join_clause)) {
+ foreach ($join_clause as $join) {
+ $result .= (' ' . strtoupper($join['type']) . ' JOIN `'
+ . $this->_table_prefix . $join['table'] . '`');
+ if ($join['alias']) {
+ $result .= ' AS ' . $join['alias'];
+ }
+ $result .= ((is_array($join['condition']))
+ ? ' USING (' . implode(',', $join['condition']) . ')'
+ : ' ON ' . $join['condition']);
+ }
+ } else {
+ $result .= ' LEFT JOIN `' . $this->_table_prefix . $join_clause . '`';
+ }
+ return $result;
+ }
+ //2}}}
+
+ function foundRows() {
global $db;
$result = false;
if ($this->include_count) {
@@ -937,9 +879,8 @@
}
return $result;
}
-
- function quote($string)
- {
+
+ function quote($string) {
global $db;
return $db->qstr($string, get_magic_quotes_runtime());
}
Modified: branches/stable_2/dotproject/classes/ui.class.php
===================================================================
--- branches/stable_2/dotproject/classes/ui.class.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/classes/ui.class.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -588,7 +588,7 @@
* @return mixed
*/
function getState( $label, $default_value = null ) {
- if (array_key_exists( $label, $this->state)) {
+ if (array_key_exists($label, $this->state)) {
return $this->state[$label];
} else if (isset($default_value)) {
$this->setState($label, $default_value);
@@ -1116,7 +1116,7 @@
$this->cells1 = array();
$this->cells2 = array();
$this->crumbs = array();
- $this->showhelp = !getDenyRead( 'help' );
+ $this->showhelp = getPermission('help', 'view');
}
/**
* Adds a table 'cell' beside the Title string
Modified: branches/stable_2/dotproject/db/upgrade_latest.php
===================================================================
--- branches/stable_2/dotproject/db/upgrade_latest.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/db/upgrade_latest.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -30,7 +30,7 @@
function dPupgrade($from_version, $to_version, $last_updated)
{
- $latest_update = '20071114'; // Set to the latest upgrade date.
+ $latest_update = '20071204'; // Set to the latest upgrade date.
if (empty($last_updated) || empty($from_version)) {
$last_updated = '00000000';
@@ -132,6 +132,14 @@
// TODO: Add new versions here. Keep this message above the default label.
case '20071104': // Last changed date.
case '20071114': // Current release
+ case '20071218':
+ // Add the permissions for task_log
+ dPmsg('Adding File Folder permissions');
+ $perms->add_object('app', 'File Folders', 'file_folders', 6, 0, 'axo');
+ $all_mods = $perms->get_group_id('all', null, 'axo');
+ $nonadmin = $perms->get_group_id('non_admin', null, 'axo');
+ $perms->add_group_object($all_mods, 'app', 'file_folders', 'axo');
+ $perms->add_group_object($nonadmin, 'app', 'file_folders', 'axo');
default:
break;
}
Modified: branches/stable_2/dotproject/db/upgrade_permissions.php
===================================================================
--- branches/stable_2/dotproject/db/upgrade_permissions.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/db/upgrade_permissions.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -4,8 +4,9 @@
die('You should not access this file directly. Instead, run the Installer in install/index.php.');
}
-if ($mode == 'upgrade')
+if ($mode == 'upgrade') {
include_once DP_BASE_DIR.'/includes/config.php';
+}
require_once DP_BASE_DIR.'/includes/main_functions.php';
require_once DP_BASE_DIR.'/install/install.inc.php';
require_once DP_BASE_DIR.'/includes/db_adodb.php';
@@ -141,37 +142,34 @@
// Worker has All on non-admin
$perms->add_acl($all_perms, null, array($worker_role), null, array($non_admin_mods), 1, 1, null, null, 'user');
-
+// Now we have the basic set up we need to create objects for all users
dPmsg('Converting admin user permissions to Administrator Role');
-// Now we have the basics set up we need to create objects for all users
+$sql = ('SELECT user_id, user_username, permission_id '
+ . 'FROM users LEFT JOIN permissions ON permission_user = users.user_id'
+ . ' WHERE permission_grant_on = ' . "'all'"
+ ." AND permission_item = -1 AND permission_value = -1");
-$sql = 'SELECT user_id, user_username, permission_id '
- . 'FROM users LEFT JOIN permissions ON permission_user = users.user_id'
- . ' WHERE permission_grant_on = ' . "'all'"
- ." AND permission_item = -1 AND permission_value = -1";
-
$res = db_exec($sql);
if ($res) {
- while ($row = db_fetch_assoc($res)) {
- // Add the basic ARO
- $perms->add_object('user', $row['user_username'], $row['user_id'], 1, 0, 'aro');
- if ($row['permission_id']) {
- $perms->add_group_object($admin_role, 'user', $row['user_id'], 'aro');
- }
- }
+ while ($row = db_fetch_assoc($res)) {
+ // Add the basic ARO
+ $perms->add_object('user', $row['user_username'], $row['user_id'], 1, 0, 'aro');
+ if ($row['permission_id']) {
+ $perms->add_group_object($admin_role, 'user', $row['user_id'], 'aro');
+ }
+ }
}
-dPmsg('Searching for add-on modules to add to new permissions');
// Upgrade permissions for custom modules
-$sql = 'SELECT mod_directory, mod_name, permissions_item_table FROM modules '
- .'WHERE mod_ui_active = 1 AND mod_type = '."'user'";
+dPmsg('Searching for add-on modules to add to new permissions');
+$sql = ('SELECT mod_directory, mod_name, permissions_item_table FROM modules '
+ .'WHERE mod_ui_active = 1 AND mod_type = '."'user'");
$custom_modules = db_loadList($sql);
-foreach($custom_modules as $mod)
-{
- $perms->addModule($mod['mod_directory'], $mod['mod_name']);
- $perms->addGroupItem($mod['mod_directory'], 'non_admin');
-
- if (isset($mod['permissions_item_table']) && $mod['permissions_item_table'])
- $perms->addModuleSection($mod['permissions_item_table']);
+foreach ($custom_modules as $mod) {
+ $perms->addModule($mod['mod_directory'], $mod['mod_name']);
+ $perms->addGroupItem($mod['mod_directory'], 'non_admin');
+ if (isset($mod['permissions_item_table']) && $mod['permissions_item_table']) {
+ $perms->addModuleSection($mod['permissions_item_table']);
+ }
}
?>
Modified: branches/stable_2/dotproject/includes/permissions.php
===================================================================
--- branches/stable_2/dotproject/includes/permissions.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/includes/permissions.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -16,8 +16,6 @@
define( 'PERM_ALL', '-1' );
-// TODO: getDeny* should return true/false instead of 1/0
-
function getReadableModule() {
global $AppUI;
$perms =& $AppUI->acl();
@@ -32,6 +30,7 @@
return null;
}
+// TODO: checkFlag should be depricated as it's old and unused
/**
* This function is used to check permissions.
*/
@@ -51,6 +50,7 @@
}
}
+// TODO: isAllowed should be depricated as it's old and unused
/**
* This function checks certain permissions for
* a given module and optionally an item_id.
@@ -93,6 +93,9 @@
return $result;
}
+
+// TODO: getDeny* should be depricated as its usage is counter-intuitive and/or assuming
+// Simply using getPermission function is clearer
function getDenyRead( $mod, $item_id = 0 ) {
return ! getPermission($mod, 'view', $item_id);
}
Modified: branches/stable_2/dotproject/modules/admin/vw_usr_perms.php
===================================================================
--- branches/stable_2/dotproject/modules/admin/vw_usr_perms.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/admin/vw_usr_perms.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -7,23 +7,35 @@
$perms =& $AppUI->acl();
$module_list = $perms->getModuleList();
+
+//get list of 'real' modules
$pgos = array();
$q = new DBQuery;
$q->addTable('modules', 'm');
$q->addQuery('mod_id, mod_name, permissions_item_table');
$q->addWhere('permissions_item_table is not null');
$q->addWhere("permissions_item_table <> ''");
-$pgo_list = $q->loadHashList('mod_name');
+$module_pgo_list = $q->loadHashList('mod_name');
$q->clear();
+//list of additional 'pseudo-modules'
+$pseudo_module_pgo_list = array('File Folders' => array('mod_id' => -1,
+ 'mod_name' => 'file_folders',
+ 'permissions_item_table' => 'file_folders')
+ );
+
+//combine modules and 'pseudo-modules'
+$pgo_list = arrayMerge($module_pgo_list, $pseudo_module_pgo_list);
+
// Build an intersection array for the modules and their listing
$modules = array();
$offset = 0;
foreach ($module_list as $module) {
- $modules[ $module['type'] . "," . $module['id']] = $module['name'];
- if ($module['type'] = 'mod' && isset($pgo_list[$module['name']]))
- $pgos[$offset] = $pgo_list[$module['name']]['permissions_item_table'];
- $offset++;
+ $modules[ $module['type'] . "," . $module['id']] = $module['name'];
+ if ($module['type'] = 'mod' && isset($pgo_list[$module['name']])) {
+ $pgos[$offset] = $pgo_list[$module['name']]['permissions_item_table'];
+ }
+ $offset++;
}
$count = 0;
Modified: branches/stable_2/dotproject/modules/calendar/calendar.class.php
===================================================================
--- branches/stable_2/dotproject/modules/calendar/calendar.class.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/calendar/calendar.class.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -117,12 +117,11 @@
setlocale(LC_ALL, $AppUI->user_lang);
$this->prev_month = new CDate($date);
-
+
setlocale(LC_TIME, 'en_AU');
$date = Date_Calc::beginOfNextMonth($d, $m, $y, FMT_TIMESTAMP_DATE);
setlocale(LC_ALL, $AppUI->user_lang);
$this->next_month = new CDate($date);
-
}
/**
Modified: branches/stable_2/dotproject/modules/companies/index.php
===================================================================
--- branches/stable_2/dotproject/modules/companies/index.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/companies/index.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -44,7 +44,7 @@
$search_string = $AppUI->getState("search_string");
}
-// $canEdit = !getDenyEdit( $m );
+// $canEdit = getPermission($m, 'edit');
// retrieve list of records
$search_string = dPformSafe($search_string, true);
Modified: branches/stable_2/dotproject/modules/contacts/csvexport.php
===================================================================
--- branches/stable_2/dotproject/modules/contacts/csvexport.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/contacts/csvexport.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -6,7 +6,7 @@
// get GETPARAMETER for contact_id
$contact_id = 1;
-$canRead = !getDenyRead( 'contacts' );
+$canRead = getPermission('contacts', 'view');
if (!$canRead) {
$AppUI->redirect( "m=public&a=access_denied" );
}
Modified: branches/stable_2/dotproject/modules/contacts/vcardexport.php
===================================================================
--- branches/stable_2/dotproject/modules/contacts/vcardexport.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/contacts/vcardexport.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -6,7 +6,7 @@
// get GETPARAMETER for contact_id
$contact_id = intval( $_GET['contact_id']);
-$canRead = !getDenyRead( 'contacts' );
+$canRead = getPermission('contacts', 'view');
if (!$canRead) {
$AppUI->redirect( "m=public&a=access_denied" );
}
Modified: branches/stable_2/dotproject/modules/contacts/vcardimport.php
===================================================================
--- branches/stable_2/dotproject/modules/contacts/vcardimport.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/contacts/vcardimport.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -3,7 +3,7 @@
die('You should not access this file directly.');
}
-$canEdit = !getDenyEdit( 'contacts' );
+$canEdit = getPermission('contacts', 'view');
if (!$canEdit) {
$AppUI->redirect( "m=public&a=access_denied" );
}
Modified: branches/stable_2/dotproject/modules/contacts/view.php
===================================================================
--- branches/stable_2/dotproject/modules/contacts/view.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/contacts/view.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -7,7 +7,7 @@
$AppUI->savePlace();
// check permissions for this record
-//$canEdit = !getDenyEdit( $m, $contact_id );
+//$canEdit = getPermission($m, 'edit', $contact_id);
//if (!$canEdit) {
// $AppUI->redirect( "m=public&a=access_denied" );
//}
Modified: branches/stable_2/dotproject/modules/departments/addedit.php
===================================================================
--- branches/stable_2/dotproject/modules/departments/addedit.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/departments/addedit.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -8,7 +8,7 @@
$company_id = isset($_GET['company_id']) ? $_GET['company_id'] : 0;
// check permissions for this department
-$canEdit = !getDenyEdit( $m, $dept_id );
+$canEdit = getPermission($m, 'edit', $dept_id);
if (!$canEdit) {
$AppUI->redirect( "m=public&a=access_denied" );
}
Modified: branches/stable_2/dotproject/modules/departments/index.php
===================================================================
--- branches/stable_2/dotproject/modules/departments/index.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/departments/index.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -21,7 +21,7 @@
}
$department = $AppUI->getState( 'DeptIdxDepartment' ) !== NULL ? $AppUI->getState( 'DeptIdxDepartment' ) : ($AppUI->user_department > 0 ? $AppUI->user_department : $company_prefix.$AppUI->user_company);
-$canRead = !getDenyRead( $m, $department);
+$canRead = getPermission($m, 'view', $department);
if (!$canRead) {
$AppUI->redirect( 'm=public&a=access_denied' );
}
Modified: branches/stable_2/dotproject/modules/departments/view.php
===================================================================
--- branches/stable_2/dotproject/modules/departments/view.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/departments/view.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -7,8 +7,8 @@
$dept_id = isset($_GET['dept_id']) ? $_GET['dept_id'] : (isset($department) ? $department : 0);
// check permissions
-$canRead = !getDenyRead( $m, $dept_id );
-$canEdit = !getDenyEdit( $m, $dept_id );
+$canRead = getPermission($m, 'view', $dept_id);
+$canEdit = getPermission($m, 'edit', $dept_id);
if (!$canRead) {
$AppUI->redirect( 'm=public&a=access_denied' );
Modified: branches/stable_2/dotproject/modules/files/addedit.php
===================================================================
--- branches/stable_2/dotproject/modules/files/addedit.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/files/addedit.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -177,11 +177,7 @@
<table cellspacing="1" cellpadding="2" width="60%">
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_( 'Folder' );?>:</td>
- <?php if ($file_id == 0 && !$ci) { ?>
- <td align="left"><?php echo arraySelectTree( $folders, 'file_folder', 'style="width:175px;" class="text"', ($file_helpdesk_item ? getHelpdeskFolder() : $folder) ); ?></td>
- <?php } else { ?>
- <td align="left"><?php echo arraySelectTree( $folders, 'file_folder', 'style="width:175px;" class="text"', ($file_helpdesk_item ? getHelpdeskFolder() : $obj->file_folder) ); ?></td>
- <?php } ?>
+ <td align="left"><?php echo arraySelectTree( $folders, 'file_folder', 'style="width:175px;" class="text"', ($file_helpdesk_item ? getHelpdeskFolder() : (($file_id == 0 && !$ci)?$folder:$obj->file_folder)) ); ?></td>
</tr>
<?php if ($file_id) { ?>
<tr>
@@ -365,7 +361,7 @@
}
function getHelpdeskFolder() {
- $q = new DBQuery();
+ $q = new DBQuery();
$q->addTable('file_folders', 'ff');
$q->addQuery('file_folder_id');
$q->addWhere('ff.file_folder_name = "Helpdesk"');
Modified: branches/stable_2/dotproject/modules/files/addedit_folder.php
===================================================================
--- branches/stable_2/dotproject/modules/files/addedit_folder.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/files/addedit_folder.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -3,50 +3,45 @@
die('You should not access this file directly.');
}
-$file_folder_parent = intval( dPgetParam( $_GET, 'file_folder_parent', 0 ) );
-$folder = intval( dPgetParam( $_GET, 'folder', 0 ) );
+$file_folder_parent = intval(dPgetParam($_GET, 'file_folder_parent', 0));
+$folder = intval(dPgetParam($_GET, 'folder', 0));
// add to allow for returning to other modules besides Files
$referrerArray = parse_url($_SERVER['HTTP_REFERER']);
$referrer = $referrerArray['query'] . $referrerArray['fragment'];
+$obj = new CFileFolder();
+// load the record data
+if ($folder && !$obj->load($folder)) {
+ $AppUI->setMsg('File Folder');
+ $AppUI->setMsg("invalidID", UI_MSG_ERROR, true);
+ $AppUI->redirect();
+}
+
// check permissions for this record
-if ($folder == 0) {
- $canEdit = true;
+if ($folder) {
+ $canRead_folder = getPermission('file_folders', 'view', $folder);
+ $canEdit_folder = getPermission('file_folders', 'edit', $folder);
} else {
- $canEdit = !getDenyEdit( $m, $folder);
+ $canAuthor_folder = getPermission('file_folders', 'add', $folder);
}
-if (!$canEdit) {
- $AppUI->redirect( "m=public&a=access_denied" );
+if (($folder && !($canEdit_folder && $canRead_folder)) || (!($folder) && !($canAuthor_folder))) {
+ $AppUI->redirect("m=public&a=access_denied");
}
-$q = new DBQuery();
-$q->addTable('file_folders');
-$q->addQuery('file_folders.*');
-$q->addWhere("file_folder_id=$folder");
-$sql = $q->prepare();
-// check if this record has dependancies to prevent deletion
$msg = '';
-$obj = new CFileFolder();
+// check if this record has dependancies to prevent deletion
if ($folder > 0) {
- $canDelete = $obj->canDelete( $msg, $folder );
+ $canDelete_folder = $obj->canDelete($msg, $folder);
}
-// load the record data
-$obj = null;
-if (!db_loadObject( $sql, $obj ) && $folder > 0) {
- $AppUI->setMsg( 'File Folder' );
- $AppUI->setMsg( "invalidID", UI_MSG_ERROR, true );
- $AppUI->redirect();
-}
-
$folders = getFolderSelectList();
// setup the title block
$ttl = $folder ? "Edit File Folder" : "Add File Folder";
-$titleBlock = new CTitleBlock( $ttl, 'folder5.png', $m, "$m.$a" );
-$titleBlock->addCrumb( "?m=files", "files list" );
-if ($canEdit && $folder > 0) {
- $titleBlock->addCrumbDelete( 'delete file folder', $canDelete, $msg );
+$titleBlock = new CTitleBlock($ttl, 'folder5.png', $m, $m . '.' . $a);
+$titleBlock->addCrumb("?m=files", "files list");
+if ($canDelete_folder) {
+ $titleBlock->addCrumbDelete('delete file folder', $canDelete_folder, $msg);
}
$titleBlock->show();
@@ -59,14 +54,14 @@
msg += "\n<?php echo $AppUI->_('Folder Name'); ?>";
f.file_folder_name.focus();
}
- if( msg.length > 0) {
+ if(msg.length > 0) {
alert('<?php echo $AppUI->_('Please type'); ?>:' + msg);
} else {
f.submit();
}
}
function delIt() {
- if (confirm( "<?php echo $AppUI->_('Delete Folder');?>" )) {
+ if (confirm("<?php echo $AppUI->_('Delete Folder');?>")) {
var f = document.folderFrm;
f.del.value='1';
f.submit();
@@ -85,19 +80,19 @@
<td width="100%" valign="top" align="center">
<table cellspacing="1" cellpadding="2" width="60%">
<tr>
- <td align="right" nowrap="nowrap"><?php echo $AppUI->_( 'Subfolder of' );?>:</td>
+ <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Subfolder of');?>:</td>
<td align="left">
<?php
$parent_folder = ($folder > 0) ? $obj->file_folder_parent : $file_folder_parent;
- echo arraySelectTree( $folders, 'file_folder_parent', 'style="width:175px;" class="text"', $parent_folder ); ?></td>
+ echo arraySelectTree($folders, 'file_folder_parent', 'style="width:175px;" class="text"', $parent_folder); ?></td>
</tr>
<tr>
- <td align="right" nowrap="nowrap"><?php echo $AppUI->_( 'Folder Name' );?>:</td>
+ <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Folder Name');?>:</td>
<td align="left"><input type="text" class="text" id="ffn" name="file_folder_name"
value="<?php echo $obj->file_folder_name; ?>" maxlength="64" /></td>
</tr>
<tr>
- <td align="right" valign="top" nowrap="nowrap"><?php echo $AppUI->_( 'Description' );?>:</td>
+ <td align="right" valign="top" nowrap="nowrap"><?php echo $AppUI->_('Description');?>:</td>
<td align="left">
<textarea name="file_folder_description" class="textarea" rows="4" style="width:270px"><?php echo $obj->file_folder_description; ?></textarea>
</td>
@@ -110,7 +105,7 @@
<input class="button" type="button" name="cancel" value="<?php echo $AppUI->_('cancel');?>" onClick="javascript:if(confirm('<?php echo $AppUI->_('Are you sure you want to cancel?'); ?>')){location.href = '?<?php echo $referrer; ?>';}" />
</td>
<td align="right">
- <input type="button" class="button" value="<?php echo $AppUI->_( 'submit' );?>" onclick="submitIt()" />
+ <input type="button" class="button" value="<?php echo $AppUI->_('submit');?>" onclick="submitIt()" />
</td>
</tr>
</form>
Modified: branches/stable_2/dotproject/modules/files/do_file_aed.php
===================================================================
--- branches/stable_2/dotproject/modules/files/do_file_aed.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/files/do_file_aed.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -4,194 +4,177 @@
}
//addfile sql
-$file_id = intval( dPgetParam( $_POST, 'file_id', 0 ) );
-$del = intval( dPgetParam( $_POST, 'del', 0 ) );
-$duplicate = intval( dPgetParam( $_POST, 'duplicate', 0 ) );
-$redirect = dPgetParam( $_POST, 'redirect', '' );
+$file_id = intval(dPgetParam($_POST, 'file_id', 0));
+$del = intval(dPgetParam($_POST, 'del', 0));
+$duplicate = intval(dPgetParam($_POST, 'duplicate', 0));
+$redirect = dPgetParam($_POST, 'redirect', '');
global $db;
-$not = dPgetParam( $_POST, 'notify', '0' );
-$notcont = dPgetParam( $_POST, 'notify_contacts', '0' );
-if ($not!='0') $not='1';
-if ($notcont!='0') $notcont='1';
+$not = dPgetParam($_POST, 'notify', '0');
+$notcont = dPgetParam($_POST, 'notify_contacts', '0');
$obj = new CFile();
if ($file_id) {
$obj->_message = 'updated';
$oldObj = new CFile();
- $oldObj->load( $file_id );
-
+ $oldObj->load($file_id);
} else {
/*
- ** @date 20070309
- ** @author gregorerhardt
- **
- ** 1. it must be (cf. #1932):
- if ($del) instead of if (!$del)
- ** 2. commented all out, because delete permissions shouldn't be module-centric,
- but file object-centric. In the CFile::delete() method there is an object-centric check for permission.
+ ** @date 20070309
+ ** @author gregorerhardt
+ **
+ ** 1. it must be (cf. #1932):
+ ** if ($del) instead of if (!$del)
+ ** 2. commented all out, because delete permissions shouldn't be module-centric,
+ ** but file object-centric. In the CFile::delete() method there is an object-centric check
+ ** for permission.
- if ($del)
- {
- $acl =& $AppUI->acl();
- if ( ! $acl->checkModule('files', 'delete'))
- {
- $AppUI->setMsg($AppUI->_( "noDeletePermission" ));
- $AppUI->redirect('m=public&a=access_denied');
+ if ($del) {
+ $acl =& $AppUI->acl();
+ if (! $acl->checkModule('files', 'delete')) {
+ $AppUI->setMsg($AppUI->_('noDeletePermission'));
+ $AppUI->redirect('m=public&a=access_denied');
}
}
*/
$obj->_message = 'added';
}
-$obj->file_category = intval( dPgetParam( $_POST, 'file_category', 0 ) );
+$obj->file_category = intval(dPgetParam($_POST, 'file_category', 0));
-$version = dPgetParam( $_POST, 'file_version', 0 );
-$revision_type = dPgetParam( $_POST, 'revision_type', 0 );
+$version = dPgetParam($_POST, 'file_version', 0);
+$revision_type = dPgetParam($_POST, 'revision_type', 0);
-if ( strcasecmp('major', $revision_type) == 0 )
-{
- $major_num = strtok($version, ".") + 1;
- $_POST['file_version']= $major_num;
+if (strcasecmp('major', $revision_type) == 0) {
+ $major_num = strtok($version, '.') + 1;
+ $_POST['file_version']= $major_num;
}
-if (!$obj->bind( $_POST )) {
- $AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
+if (!$obj->bind($_POST)) {
+ $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
$AppUI->redirect($redirect);
}
// prepare (and translate) the module name ready for the suffix
-$AppUI->setMsg( 'File' );
+$AppUI->setMsg('File');
// duplicate a file
if ($duplicate) {
- $obj->load( $file_id );
+ $obj->load($file_id);
$new_file = new CFile();
$new_file = $obj->duplicate();
if (!($dup_realname = $obj->duplicateFile($obj->file_project, $obj->file_real_filename))) {
- $AppUI->setMsg( 'Could not duplicate file, check file permissions', UI_MSG_ERROR );
+ $AppUI->setMsg('Could not duplicate file, check file permissions', UI_MSG_ERROR);
$AppUI->redirect();
} else {
$new_file->file_real_filename = $dup_realname;
$new_file->file_date = str_replace("'", '', $db->DBTimeStamp(time()));
-
- $q = new DBQuery;
- $q->addTable('files');
- $q->addQuery('file_version_id');
- $q->addOrder('file_version_id DESC');
- $q->setLimit(1);
- $sql = $q->prepare();
- $q->clear();
- $latest_file_version = db_loadResult($sql);
- $new_file->file_version_id = $latest_file_version + 1;
-
-
- if (($msg = $new_file->store())) {
- $AppUI->setMsg( $msg, UI_MSG_ERROR );
- $AppUI->redirect($redirect);
+ $new_file->file_version_id = getNextVersionID();
+
+ if ($msg = $new_file->store()) {
+ $AppUI->setMsg($msg, UI_MSG_ERROR);
} else {
- $AppUI->setMsg( "duplicated", UI_MSG_OK, true );
- $AppUI->redirect( $redirect );
+ $AppUI->setMsg('duplicated', UI_MSG_OK, true);
}
+ $AppUI->redirect($redirect);
}
}
// delete the file
if ($del) {
- $obj->load( $file_id );
+ $obj->load($file_id);
if (($msg = $obj->delete())) {
- $AppUI->setMsg( $msg, UI_MSG_ERROR );
+ $AppUI->setMsg($msg, UI_MSG_ERROR);
$AppUI->redirect();
} else {
- if ($not=='1') $obj->notify();
- if ($notcont=='1') $obj->notifyContacts();
- $AppUI->setMsg( "deleted", UI_MSG_OK, true );
- $AppUI->redirect( $redirect );
+ if ($not) {
+ $obj->notify();
+ }
+ if ($notcont) {
+ $obj->notifyContacts();
+ }
+ $AppUI->setMsg('deleted', UI_MSG_OK, true);
+ $AppUI->redirect($redirect);
}
}
-if (!ini_get('safe_mode'))
- set_time_limit( 600 );
-ignore_user_abort( 1 );
+if (!(ini_get('safe_mode'))) {
+ set_time_limit(600);
+}
+ignore_user_abort(1);
-//echo "<pre>";print_r($_POST);echo "</pre>";die;
+//echo '<pre>';print_r($_POST);echo '</pre>';die;
$upload = null;
-if (isset( $_FILES['formfile'] )) {
+if (isset($_FILES['formfile'])) {
$upload = $_FILES['formfile'];
if ($upload['size'] < 1) {
if (!$file_id) {
- $AppUI->setMsg( 'Upload file size is zero. Process aborted.', UI_MSG_ERROR );
+ $AppUI->setMsg('Upload file size is zero. Process aborted.', UI_MSG_ERROR);
$AppUI->redirect($redirect);
}
} else {
-
- // store file with a unique name
+ // store file with a unique name
$obj->file_name = $upload['name'];
$obj->file_type = $upload['type'];
$obj->file_size = $upload['size'];
$obj->file_date = str_replace("'", '', $db->DBTimeStamp(time()));
- $obj->file_real_filename = uniqid( rand() );
-
- $res = $obj->moveTemp( $upload );
+ $obj->file_real_filename = uniqid(rand());
+
+ $res = $obj->moveTemp($upload);
if (!$res) {
- $AppUI->setMsg( 'File could not be written', UI_MSG_ERROR );
+ $AppUI->setMsg('File could not be written', UI_MSG_ERROR);
$AppUI->redirect($redirect);
}
-
}
}
// move the file on filesystem if the affiliated project was changed
-if ($file_id && ($obj->file_project != $oldObj->file_project) ) {
- $res = $obj->moveFile( $oldObj->file_project, $oldObj->file_real_filename );
+if ($file_id && ($obj->file_project != $oldObj->file_project)) {
+ $res = $obj->moveFile($oldObj->file_project, $oldObj->file_real_filename);
if (!$res) {
- $AppUI->setMsg( 'File could not be moved', UI_MSG_ERROR );
+ $AppUI->setMsg('File could not be moved', UI_MSG_ERROR);
$AppUI->redirect($redirect);
}
}
if (!$file_id) {
$obj->file_owner = $AppUI->user_id;
- if (! $obj->file_version_id)
- {
- $q = new DBQuery;
- $q->addTable('files');
- $q->addQuery('file_version_id');
- $q->addOrder('file_version_id DESC');
- $q->setLimit(1);
- $sql = $q->prepare();
- $q->clear();
- $latest_file_version = db_loadResult($sql);
- $obj->file_version_id = $latest_file_version + 1;
+ if (! $obj->file_version_id) {
+ $obj->file_version_id = getNextVersionID();
} else {
$q = new DBQuery;
$q->addTable('files');
$q->addUpdate('file_checkout', '');
- $q->addWhere("file_version_id = $obj->file_version_id");
+ $q->addWhere('file_version_id = ' . $obj->file_version_id);
$q->exec();
$q->clear();
}
}
//print_r($obj);die;
if (($msg = $obj->store())) {
- $AppUI->setMsg( $msg, UI_MSG_ERROR );
+ $AppUI->setMsg($msg, UI_MSG_ERROR);
} else {
-
// Notification
$obj->load($obj->file_id);
- if ($not=='1') $obj->notify();
- if ($notcont=='1') $obj->notifyContacts();
-
- // Delete the existing (old) file in case of file replacement (through addedit not through c/o-versions)
+ if ($not) {
+ $obj->notify();
+ }
+ if ($notcont) {
+ $obj->notifyContacts();
+ }
+
+ // Delete the existing (old) file in case of file replacement
+ // (through addedit not through c/o-versions)
if (($file_id) && ($upload['size'] > 0)) {
if (($oldObj->deleteFile())) {
$AppUI->setMsg('replaced', UI_MSG_OK, true);
} else {
- $AppUI->setMsg($file_id ? 'updated' : 'added' . '; unable to delete existing file', UI_MSG_OK, true);
+ $AppUI->setMsg($file_id ? 'updated' : 'added' . '; unable to delete existing file',
+ UI_MSG_OK, true);
}
} else {
- $AppUI->setMsg( $file_id ? 'updated' : 'added', UI_MSG_OK, true );
+ $AppUI->setMsg($file_id ? 'updated' : 'added', UI_MSG_OK, true);
}
/* Workaround for indexing large files:
Modified: branches/stable_2/dotproject/modules/files/do_files_bulk_aed.php
===================================================================
--- branches/stable_2/dotproject/modules/files/do_files_bulk_aed.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/files/do_files_bulk_aed.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -1,35 +1,37 @@
<?php /* fileS $Id$ */
-if (!defined('DP_BASE_DIR')){
+if (!defined('DP_BASE_DIR')) {
die('You should not access this file directly.');
}
global $AppUI;
-$selected = dPgetParam( $_POST, 'bulk_selected_file', 0 );
-$redirect = dPgetParam( $_POST, 'redirect', '' );
-$bulk_file_project = dPgetParam( $_POST, 'bulk_file_project', 'O' );
-$bulk_file_folder = dPgetParam( $_POST, 'bulk_file_folder', 'O' );
-//print_r($_POST);die;
-if (is_array($selected) && count( $selected )) {
+$selected = dPgetParam($_POST, 'bulk_selected_file', 0);
+$redirect = dPgetParam($_POST, 'redirect', '');
+$bulk_file_project = dPgetParam($_POST, 'bulk_file_project', 'O');
+$bulk_file_folder = dPgetParam($_POST, 'bulk_file_folder', 'O');
+
+if (is_array($selected) && count($selected)) {
$upd_file = new CFile();
foreach ($selected as $key => $val) {
- if ($key)
+ if ($key) {
$upd_file->load($key);
+ }
- if ( isset($_POST['bulk_file_project']) && $bulk_file_project!='' && $bulk_file_project!='O') {
+ if (isset($_POST['bulk_file_project']) && $bulk_file_project!=''
+ && $bulk_file_project!='O') {
if ($upd_file->file_id) {
// move the file on filesystem if the affiliated project was changed
- if ( $upd_file->file_project != $bulk_file_project ) {
+ if ($upd_file->file_project != $bulk_file_project) {
$oldProject = $upd_file->file_project;
$upd_file->file_project = $bulk_file_project;
- $res = $upd_file->moveFile( $oldProject, $upd_file->file_real_filename );
+ $res = $upd_file->moveFile($oldProject, $upd_file->file_real_filename);
if (!$res) {
- $AppUI->setMsg( 'At least one File could not be moved', UI_MSG_ERROR );
+ $AppUI->setMsg('At least one File could not be moved', UI_MSG_ERROR);
}
}
$upd_file->store();
}
}
- if ( isset($_POST['bulk_file_folder']) && $bulk_file_folder!='' && $bulk_file_folder!='O') {
+ if (isset($_POST['bulk_file_folder']) && $bulk_file_folder!='' && $bulk_file_folder!='O') {
if ($upd_file->file_id) {
$upd_file->file_folder = $bulk_file_folder;
$upd_file->store();
Modified: branches/stable_2/dotproject/modules/files/files.class.php
===================================================================
--- branches/stable_2/dotproject/modules/files/files.class.php 2007-12-19 02:58:07 UTC (rev 5584)
+++ branches/stable_2/dotproject/modules/files/files.class.php 2007-12-19 23:38:33 UTC (rev 5585)
@@ -3,17 +3,17 @@
die('You should not access this file directly.');
}
-require_once( $AppUI->getSystemClass( 'libmail' ) );
-require_once( $AppUI->getSystemClass( 'dp' ) );
-require_once( $AppUI->getSystemClass( 'date' ) );
-require_once( $AppUI->getModuleClass( 'tasks' ) );
-require_once( $AppUI->getModuleClass( 'projects' ) );
+require_once ($AppUI->getSystemClass('libmail'));
+require_once ($AppUI->getSystemClass('dp'));
+require_once ($AppUI->getSystemClass('date'));
+require_once ($AppUI->getModuleClass('tasks'));
+require_once ($AppUI->getModuleClass('projects'));
global $helpdesk_available;
/** The helpdesk module seems to no longer have files support (at least in the dotmods CVS)
so this breaks if helpdesk is available. This is NOT the way to build co-operating modules.
if ($helpdesk_available = $AppUI->isActiveModule('helpdesk')) {
- require_once( $AppUI->getModuleClass( 'helpdesk' ) );
+ require_once($AppUI->getModuleClass('helpdesk'));
}
*/
$helpdesk_available = false;
@@ -21,7 +21,7 @@
* File Class
*/
class CFile extends CDpObject {
-
+
var $file_id = NULL;
var $file_version_id = NULL;
var $file_project = NULL;
@@ -39,17 +39,18 @@
var $file_folder = NULL;
var $file_checkout = NULL;
var $file_co_reason = NULL;
-
- // This "breaks" check-in/upload if helpdesk is not present class variable needs to be added "dymanically"
+
+ // This "breaks" check-in/upload if helpdesk is not present.
+ // class variable needs to be added "dymanically"
//var $file_helpdesk_item = NULL;
-
+
function CFile() {
global $AppUI, $helpdesk_available;
if ($helpdesk_available) {
$this->file_helpdesk_item = NULL;
}
- $this->CDpObject( 'files', 'file_id' );
+ $this->CDpObject('files', 'file_id');
}
function store() {
@@ -67,30 +68,32 @@
// create task log with information about the file that was uploaded
$task_log = new CHDTaskLog();
$task_log->task_log_help_desk_id = $this->_hditem->item_id;
- if ($this->_message != "deleted") {
- $task_log->task_log_name = "File ". $this->file_name ." uploaded";
+ if ($this->_message != 'deleted') {
+ $task_log->task_log_name = 'File ' . $this->file_name .' uploaded';
} else {
- $task_log->task_log_name = "File ". $this->file_name ." deleted";
+ $task_log->task_log_name = 'File ' . $this->file_name .' deleted';
}
$task_log->task_log_description = $this->file_description;
$task_log->task_log_creator = $AppUI->user_id;
$date = new CDate();
- $task_log->task_log_date = $date->format( FMT_DATETIME_MYSQL );
+ $task_log->task_log_date = $date->format(FMT_DATETIME_MYSQL);
if ($msg = $task_log->store()) {
- $AppUI->setMsg( $msg, UI_MSG_ERROR );
+ $AppUI->setMsg($msg, UI_MSG_ERROR);
}
}
return NULL;
}
-
+
function canAdmin() {
global $AppUI;
-
- if (! $this->file_project)
+
+ if (! $this->file_project) {
return false;
- if (! $this->file_id)
+ }
+ if (! $this->file_id) {
return false;
-
+ }
+
$result = false;
$this->_query->clear();
$this->_query->addTable('projects');
@@ -99,20 +102,20 @@
$res = $this->_query->exec();
if ($res && $row = db_fetch_assoc($res)) {
if ($row['project_owner'] == $AppUI->user_id)
- $result = true;
- }
+ $result = true;
+ }
$this->_query->clear();
return $result;
}
-
+
function check() {
// ensure the integrity of some variables
- $this->file_id = intval( $this->file_id );
+ $this->file_id = intval($this->file_id);
$this->file_version_id = intval($this->file_version_id);
- $this->file_parent = intval( $this->file_parent );
- $this->file_task = intval( $this->file_task );
- $this->file_project = intval( $this->file_project );
-
+ $this->file_parent = intval($this->file_parent);
+ $this->file_task = intval($this->file_task);
+ $this->file_project = intval($this->file_project);
+
return NULL; // object is ok
}
@@ -120,117 +123,112 @@
$q = new DBQuery;
$q->addTable('files');
$q->addUpdate('file_checkout', $userId);
- $q->addUpdate('file_co_reason', $coReason );
- $q->addWhere('file_id = '.$fileId);
+ $q->addUpdate('file_co_reason', $coReason);
+ $q->addWhere('file_id = ' . $fileId);
$q->exec();
$q->clear();
-
+
return true;
}
function delete() {
global $helpdesk_available;
- if (!$this->canDelete( $msg ))
- return $msg;
- $this->_message = "deleted";
- addHistory('files', $this->file_id, 'delete', $this->file_name, $this->file_project);
+
+ // delete the main table reference
+ $message = parent :: delete($this->file_id, $this->file_name, $this->file_project);
+ if ($message) {
+ return $message;
+ }
+
// remove the file from the file system
$this->deleteFile();
+
// delete any index entries
$q = new DBQuery;
$q->setDelete('files_index');
$q->addQuery('*');
- $q->addWhere("file_id = $this->file_id");
+ $q->addWhere('file_id = ' .$this->file_id);
if (!$q->exec()) {
$q->clear();
return db_error();
}
- // delete the main table reference
$q->clear();
- $q->setDelete('files');
- $q->addQuery('*');
- $q->addWhere("file_id = $this->file_id");
- if (!$q->exec()) {
- $q->clear();
- return db_error();
- }
- $q->clear();
+ $this->_message = 'deleted';
+
if ($helpdesk_available && $this->file_helpdesk_item != 0) {
$this->addHelpDeskTaskLog();
}
- return NULL;
+
+ return null;
}
// delete File from File System
function deleteFile() {
global $dPconfig;
- return @unlink( DP_BASE_DIR.'/files/'.$this->file_project.'/'.$this->file_real_filename );
+ return @unlink(DP_BASE_DIR . '/files/' . $this->file_project . '/'
+ . $this->file_real_filename);
}
// move the file if the affiliated project was changed
- function moveFile( $oldProj, $realname ) {
+ function moveFile($oldProj, $realname) {
global $AppUI, $dPconfig;
- if (!is_dir(DP_BASE_DIR.'/files/'.$this->file_project)) {
- $res = mkdir( DP_BASE_DIR.'/files/'.$this->file_project, 0777 );
- if (!$res) {
- $AppUI->setMsg( "Upload folder not setup to accept uploads - change permission on files/ directory.", UI_MSG_ALLERT );
- return false;
- }
+ if (!is_dir(DP_BASE_DIR . '/files/' . $this->file_project)) {
+ $res = mkdir(DP_BASE_DIR . '/files/' . $this->file_project, 0777);
+ if (!$res) {
+ $AppUI->setMsg('Upload folder not setup to accept uploads'
+ . ' - change permission on files/ directory.', UI_MSG_ALLERT);
+ return false;
+ }
}
- $res = rename(DP_BASE_DIR.'/files/'.$oldProj.'/'.$realname, DP_BASE_DIR.'/files/'.$this->file_project.'/'.$realname);
-
- if (!$res) {
- return false;
- }
- return true;
+ $res = rename(DP_BASE_DIR . '/files/' . $oldProj . '/' . $realname,
+ DP_BASE_DIR . '/files/' . $this->file_project . '/' . $realname);
+
+ return $res;
}
// duplicate a file into root
- function duplicateFile( $oldProj, $realname ) {
+ function duplicateFile($oldProj, $realname) {
global $AppUI, $dPconfig;
if (!is_dir(DP_BASE_DIR.'/files/0')) {
- $res = mkdir( DP_BASE_DIR.'/files/0', 0777 );
- if (!$res) {
- $AppUI->setMsg( "Upload folder not setup to accept uploads - change permission on files/ directory.", UI_MSG_ALLERT );
- return false;
- }
+ $res = mkdir(DP_BASE_DIR.'/files/0', 0777);
+ if (!$res) {
+ $AppUI->setMsg('Upload folder not setup to accept uploads.'
+ . ' Change permission on files/ directory.', UI_MSG_ALLERT);
+ return false;
+ }
}
- $dest_realname = uniqid( rand() );
- $res = copy(DP_BASE_DIR.'/files/'.$oldProj.'/'.$realname, DP_BASE_DIR.'/files/0/'.$dest_realname);
-
- if (!$res) {
- return false;
- }
- return $dest_realname;
+ $dest_realname = uniqid(rand());
+ $res = copy(DP_BASE_DIR . '/files/' . $oldProj . '/' . $realname,
+ DP_BASE_DIR . '/files/0/' . $dest_realname);
+
+ return ((!$res) ? false : $dest_realname);
}
-
+
// move a file from a temporary (uploaded) location to the file system
- function moveTemp( $upload ) {
+ function moveTemp($upload) {
global $AppUI, $dPconfig;
// check that directories are created
if (!is_dir(DP_BASE_DIR.'/files')) {
- $res = mkdir( DP_BASE_DIR.'/files', 0777 );
+ $res = mkdir(DP_BASE_DIR.'/files', 0777);
if (!$res) {
- return false;
- }
+ return false;
+ }
}
if (!is_dir(DP_BASE_DIR.'/files/'.$this->file_project)) {
- $res = mkdir( DP_BASE_DIR.'/files/'.$this->file_project, 0777 );
- if (!$res) {
- $AppUI->setMsg( "Upload folder not setup to accept uploads - change permission on files/ directory.", UI_MSG_ALLERT );
- return false;
- }
+ $res = mkdir(DP_BASE_DIR.'/files/'.$this->file_project, 0777);
+ if (!$res) {
+ $AppUI->setMsg('Upload folder not setup to accept uploads'
+ . ' - change permission on files/ directory.', UI_MSG_ALLERT);
+ return false;
+ }
}
-
-
+
+
$this->_filepath = DP_BASE_DIR.'/files/'.$this->file_project.'/'.$this->file_real_filename;
// move it
- $res = move_uploaded_file( $upload['tmp_name'], $this->_filepath );
- if (!$res) {
- return false;
- }
- return true;
+ $res = move_uploaded_file($upload['tmp_name'], $this->_filepath);
+ return $res;
}
// parse file for indexing
@@ -238,67 +236,68 @@
GLOBAL $AppUI, $dPconfig;
// get the parser application
$parser = @$dPconfig['parser_' . $this->file_type];
- if (!$parser)
+ if (!$parser) {
$parser = $dPconfig['parser_default'];
- if (!$parser)
+ }
+ if (!$parser) {
return false;
+ }
// buffer the file
- $this->_filepath = DP_BASE_DIR.'/files/'.$this->file_project.'/'.$this->file_real_filename;
- $fp = fopen( $this->_filepath, "rb" );
- $x = fread( $fp, $this->file_size );
- fclose( $fp );
+ $this->_filepath = (DP_BASE_DIR . '/files/' . $this->file_project . '/'
+ . $this->file_real_filename);
+ $fp = fopen($this->_filepath, 'rb');
+ $x = fread($fp, $this->file_size);
+ fclose($fp);
+
// parse it
- $parser = $parser . " " . $this->_filepath;
- $pos = strpos( $parser, '/pdf' );
- if (false !== $pos) {
- $x = `$parser -`;
- } else {
- $x = `$parser`;
- }
+ $parser = $parser . ' ' . $this->_filepath;
+ $pos = strpos($parser, '/pdf');
+ $x = (($pos !== false) ? `$parser -` : `$parser`);
+
// if nothing, return
- if (strlen( $x ) < 1) {
+ if (strlen($x) < 1) {
return 0;
}
// remove punctuation and parse the strings
- $x = str_replace( array( ".", ",", "!", "@", "(", ")" ), " ", $x );
- $warr = split( "[[:space:]]", $x );
-
+ $x = str_replace(array('.', ',', '!', '@', '(', ')'), ' ', $x);
+ $warr = split('[[:space:]]', $x);
+
$wordarr = array();
- $nwords = count( $warr );
+ $nwords = count($warr);
for ($x=0; $x < $nwords; $x++) {
$newword = $warr[$x];
- if (!ereg( "[[:punct:]]", $newword )
- && strlen( trim( $newword ) ) > 2
- && !ereg( "[[:digit:]]", $newword )) {
- $wordarr[] = array( "word" => $newword, "wordplace" => $x );
+ if (!ereg('[[:punct:]]', $newword) && !ereg('[[:digit:]]', $newword)
+ && strlen(trim($newword)) > 2) {
+ $wordarr[] = array('word' => $newword, 'wordplace' => $x);
}
}
- db_exec( "LOCK TABLES files_index WRITE" );
+ db_exec('LOCK TABLES files_index WRITE');
// filter out common strings
$ignore = array();
- include DP_BASE_DIR.'/modules/files/file_index_ignore.php';
+ include_once (DP_BASE_DIR . '/modules/files/file_index_ignore.php');
foreach ($ignore as $w) {
- unset( $wordarr[$w] );
+ unset($wordarr[$w]);
}
// insert the strings into the table
- while (list( $key, $val ) = each( $wordarr )) {
+ while (list($key, $val) = each($wordarr)) {
$q = new DBQuery;
$q->addTable('files_index');
-
- $q->addReplace("file_id", $this->file_id);
- $q->addReplace("word", $wordarr[$key]['word']);
- $q->addReplace("word_placement", $wordarr[$key]['wordplace']);
+
+ $q->addReplace('file_id', $this->file_id);
+ $q->addReplace('word', $wordarr[$key]['word']);
+ $q->addReplace('word_placement', $wordarr[$key]['wordplace']);
$q->exec();
$q->clear();
}
-
- db_exec( "UNLOCK TABLES;" );
+
+ db_exec('UNLOCK TABLES;');
return nwords;
}
//function notifies about file changing
function notify() {
GLOBAL $AppUI, $dPconfig, $locale_char_set, $helpdesk_available;
+
// if helpdesk_item is available send notification to assigned users
if ($helpdesk_available && $this->file_helpdesk_item != 0) {
$this->_hditem = new CHelpDeskItem();
@@ -308,40 +307,49 @@
$task_log_help_desk_id = $this->_hditem->item_id;
// send notifcation about new log entry
// 2 = TASK_LOG
- $this->_hditem->notify( 2, $task_log->task_log_id );
+ $this->_hditem->notify(2, $task_log->task_log_id);
}
+
//if no project specified than we will not do anything
if ($this->file_project != 0) {
$this->_project = new CProject();
$this->_project->load($this->file_project);
$mail = new Mail;
-
+
if ($this->file_task == 0) { //notify all developers
- $mail->Subject( $this->_project->project_name."::".$this->file_name, $locale_char_set);
+ $mail->Subject($this->_project->project_name . '::' . $this->file_name,
+ $locale_char_set);
} else { //notify all assigned users
$this->_task = new CTask();
$this->_task->load($this->file_task);
- $mail->Subject( $this->_project->project_name."::".$this->_task->task_name."::".$this->file_name, $locale_char_set);
+ $mail->Subject($this->_project->project_name . '::' . $this->_task->task_name
+ . '::' . $this->file_name, $locale_char_set);
}
- $body = $AppUI->_('Project').": ".$this->_project->project_name;
- $body .= "\n".$AppUI->_('URL').': ' . DP_BASE_URL . '/index.php?m=projects&a=view&project_id='.$this->_project->project_id;
+ $body = $AppUI->_('Project').': '.$this->_project->project_name;
+ $body .= ("\n" . $AppUI->_('URL') . ': ' . DP_BASE_URL
+ . '/index.php?m=projects&a=view&project_id=' . $this->_project->project_id);
+ $q = new DBQuery;
if (intval($this->_task->task_id) != 0) {
- $body .= "\n\n".$AppUI->_('Task').": ".$this->_task->task_name;
- $body .= "\n".$AppUI->_('URL').': '.DP_BASE_URL . '/index.php?m=tasks&a=view&task_id='.$this->_task->task_id;
- $body .= "\n" . $AppUI->_('Description') . ":" . "\n".$this->_task->task_description;
+ $body .= "\n\n" . $AppUI->_('Task') . ': ' . $this->_task->task_name;
+ $body .= ("\n" . $AppUI->_('URL') . ': ' . DP_BASE_URL
+ . '/index.php?m=tasks&a=view&task_id=' . $this->_task->task_id);
+ $body .= ("\n" . $AppUI->_('Description') . ':' . "\n"
+ . $this->_task->task_description);
//preparing users array
- $q = new DBQuery;
$q->addTable('tasks', 't');
- $q->addQuery('t.task_id, cc.contact_email as creator_email, cc.contact_first_name as
- creator_first_name, cc.contact_last_name as creator_last_name,
- oc.contact_email as owner_email, oc.contact_first_name as owner_first_name,
- oc.contact_last_name as owner_last_name, a.user_id as assignee_id,
- ac.contact_email as assignee_email, ac.contact_first_name as
- assignee_first_name, ac.contact_last_name as assignee_last_name');
+ $q->addQuery('t.task_id, cc.contact_email as creator_email'
+ . ', cc.contact_first_name as creator_first_name'
+ . ', cc.contact_last_name as creator_last_name'
+ . ', oc.contact_email as owner_email'
+ . ', oc.contact_first_name as owner_first_name'
+ . ', oc.contact_last_name as owner_last_name'
+ . ', a.user_id as assignee_id, ac.contact_email as assignee_email'
+ . ', ac.contact_first_name as assignee_first_name'
+ . ', ac.contact_last_name as assignee_last_name');
$q->addJoin('user_tasks', 'u', 'u.task_id = t.task_id');
$q->addJoin('users', 'o', 'o.user_id = t.task_owner');
$q->addJoin('contacts', 'oc', 'o.user_contact = oc.contact_id');
@@ -353,7 +361,6 @@
$this->_users = $q->loadList();
} else {
//find project owner and notify him about new or modified file
- $q = new DBQuery;
$q->addTable('users', 'u');
$q->addTable('projects', 'p');
$q->addQuery('u.*');
@@ -361,37 +368,42 @@
$q->addWhere('p.project_id = '.$this->file_project);
$this->_users = $q->loadList();
}
- $body .= "\n\nFile ".$this->file_name." was ".$this->_message." by ".$AppUI->user_first_name . " " . $AppUI->user_last_name;
- if ($this->_message != "deleted") {
- $body .= "\n".$AppUI->_('URL').': ' . DP_BASE_URL . '/fileviewer.php?file_id='.$this->file_id;
- $body .= "\n" . $AppUI->_('Description') . ":" . "\n".$this->file_description;
+ $body .= ("\n\nFile " . $this->file_name . ' was ' . $this->_message . ' by '
+ . $AppUI->user_first_name . ' ' . $AppUI->user_last_name);
+ if ($this->_message != 'deleted') {
+ $body .= ("\n" . $AppUI->_('URL') . ': ' . DP_BASE_URL
+ . '/fileviewer.php?file_id=' . $this->file_id);
+ $body .= "\n" . $AppUI->_('Description') . ':' . "\n" . $this->file_description;
}
//send mail
- $mail->Body( $body, isset( $GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : "" );
- $mail->From ( '"' . $AppUI->user_first_name . " " . $AppUI->user_last_name . '" <' . $AppUI->user_email . '>');
+ $mail->Body($body,
+ (isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''));
+ $mail->From ('"' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name . '" <'
+ . $AppUI->user_email . '>');
if (intval($this->_task->task_id) != 0) {
foreach ($this->_users as $row) {
- if ($row['assignee_id'] != $AppUI->user_id) {
- if ($mail->ValidEmail($row['assignee_email'])) {
- $mail->To( $row['assignee_email'], true );
- $mail->Send();
- }
+ if ($row['assignee_id'] != $AppUI->user_id
+ && $mail->ValidEmail($row['assignee_email'])) {
+ //send e-mails
+ $mail->To($row['assignee_email'], true);
+ $mail->Send();
}
}
- } else { //sending mail to project owner
- foreach ($this->_users as $row) { //there should be only one row
+ } else {
+ foreach ($this->_users as $row) {
if ($row['user_id'] != $AppUI->user_id) {
if ($mail->ValidEmail($row['user_email'])) {
- $mail->To( $row['user_email'], true );
+ //sending mail to project owner (there should be only one)
+ $mail->To($row['user_email'], true);
$mail->Send();
}
}
- }
+ }
}
}
- }//notify
+ }
function notifyContacts() {
GLOBAL $AppUI, $dPconfig, $locale_char_set;
@@ -399,114 +411,125 @@
if ($this->file_project != 0) {
$this->_project = new CProject();
$this->_project->load($this->file_project);
- $mail = new Mail;
-
+ $mail = new Mail;
+
if ($this->file_task == 0) { //notify all developers
- $mail->Subject( $AppUI->_('Project').": ".$this->_project->project_name."::".$this->file_name, $locale_char_set);
- } else { //notify all assigned users
+ $mail->Subject($AppUI->_('Project') . ': ' . $this->_project->project_name
+ . '::' . $this->file_name, $locale_char_set);
+ } else { //notify all assigned users
$this->_task = new CTask();
$this->_task->load($this->file_task);
- $mail->Subject( $AppUI->_('Project').": ".$this->_project->project_name."::".$this->_task->task_name."::".$this->file_name, $locale_char_set);
+ $mail->Subject($AppUI->_('Project') . ': ' . $this->_project->project_name . '::'
+ . $this->_task->task_name . '::' . $this->file_name,
+ $locale_char_set);
}
-
- $body = $AppUI->_('Project').": ".$this->_project->project_name;
- $body .= "\n".$AppUI->_('URL').': '.DP_BASE_URL.'/index.php?m=projects&a=view&project_id='.$this->_project->project_id;
+ $body = $AppUI->_('Project') . ': ' . $this->_project->project_name;
+ $body .= ("\n" . $AppUI->_('URL') . ': ' . DP_BASE_URL
+ . '/index.php?m=projects&a=view&project_id=' . $this->_project->project_id);
+
+ $q = new DBQuery;
if (intval($this->_task->task_id) != 0) {
- $body .= "\n\n".$AppUI->_('Task').": ".$this->_task->task_name;
- $body .= "\n".$AppUI->_('URL').': '.DP_BASE_URL.'/index.php?m=tasks&a=view&task_id='.$this->_task->task_id;
- $body .= "\n" . $AppUI->_('Description') . ":\n".$this->_task->task_description;
-
- $q = new DBQuery;
+ $body .= "\n\n" . $AppUI->_('Task') . ': ' . $this->_task->task_name;
+ $body .= ("\n" . $AppUI->_('URL') . ': ' . DP_BASE_URL
+ . '/index.php?m=tasks&a=view&task_id=' . $this->_task->task_id);
+ $body .= "\n" . $AppUI->_('Description') . ":\n" . $this->_task->task_description;
+
$q->addTable('project_contacts', 'pc');
- $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name');
+ $q->addQuery('c.contact_email as contact_email'
+ . ', c.contact_first_name as contact_first_name'
+ . ', c.contact_last_name as contact_last_name');
$q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id');
$q->addWhere('pc.project_id = '.$this->_project->project_id);
- $sql = '('.$q->prepare().')';
- $q->clear();
- //$sql = "(SELECT contacts.contact_last_name, contacts.contact_email, contacts.contact_first_name FROM project_contacts INNER JOIN contacts ON (project_contacts.contact_id = contacts.contact_id) WHERE (project_contacts.project_id = ".$this->_project->project_id.")) ";
- $sql .= " UNION ";
+ $sql = '(' . $q->prepare() . ')';
+ $q->clear();
+
+ $sql .= ' UNION ';
+
$q->addTable('task_contacts', 'tc');
- $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name');
+ $q->addQuery('c.contact_email as contact_email'
+ . ', c.contact_first_name as contact_first_name'
+ . ', c.contact_last_name as contact_last_name');
$q->addJoin('contacts', 'c', 'c.contact_id = tc.contact_id');
- $q->addWhere('tc.task_id = '.$this->_task->task_id);
- $sql .= '('.$q->prepare().')';
- $q->clear();
- //$sql .= "(SELECT contacts.contact_last_name, contacts.contact_email, contacts.contact_first_name FROM task_contacts INNER JOIN contacts ON (task_contacts.contact_id = contacts.contact_id) WHERE (task_contacts.task_id = ".$this->_task->task_id."));";
+ $q->addWhere('tc.task_id = ' . $this->_task->task_id);
+ $sql .= '(' . $q->prepare() . ')';
+ $q->clear();
+
$this->_users = db_loadList($sql);
} else {
- $q = new DBQuery;
+
$q->addTable('project_contacts', 'pc');
$q->addQuery('pc.project_id, pc.contact_id');
- $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name');
+ $q->addQuery('c.contact_email as contact_email'
+ . ', c.contact_first_name as contact_first_name'
+ . ', c.contact_last_name as contact_last_name');
$q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id');
- $q->addWhere('pc.project_id = '.$this->file_project);
-
+ $q->addWhere('pc.project_id = ' . $this->file_project);
+
$this->_users = $q->loadList();
$q->clear();
}
- $body .= "\n\nFile ".$this->file_name." was ".$this->_message." by ".$AppUI->user_first_name . " " . $AppUI->user_last_name;
- if ($this->_message != "deleted") {
- $body .= "\n".$AppUI->_('URL').': '.DP_BASE_URL.'/fileviewer.php?file_id='.$this->file_id;
- $body .= "\n" . $AppUI->_('Description') . ":\n".$this->file_description;
+ $body .= ("\n\nFile " . $this->file_name . ' was ' . $this->_message . ' by '
+ . $AppUI->user_first_name . ' ' . $AppUI->user_last_name);
+ if ($this->_message != 'deleted') {
+ $body .= ("\n" . $AppUI->_('URL') . ': ' . DP_BASE_URL
+ . '/fileviewer.php?file_id=' . $this->file_id);
+ $body .= "\n" . $AppUI->_('Description') . ":\n" . $this->file_description;
}
- //send mail
- $mail->Body( $body, isset( $GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : "" );
- $mail->From ( '"' . $AppUI->user_first_name . " " . $AppUI->user_last_name . '" <' . $AppUI->user_email . '>');
-
-
-
+ // send mail
+ $mail->Body($body,
+ (isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''));
+ $mail->From ('"' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name . '" <'
+ . $AppUI->user_email . '>');
+
+
foreach ($this->_users as $row) {
-
if ($mail->ValidEmail($row['contact_email'])) {
- $mail->To( $row['contact_email'], true );
+ $mail->To($row['contact_email'], true);
$mail->Send();
}
- }
- return '';
+ }
}
+ return '';
}
- function getOwner()
- {
+ function getOwner() {
$owner = '';
- if (! $this->file_owner)
+ if (! $this->file_owner) {
return $owner;
-
- $this->_query->clear();
- $this->_query->addTable('users', 'a');
- $this->_query->leftJoin('contacts', 'b', 'b.contact_id = a.user_contact');
- $this->_query->addQuery('contact_first_name, contact_last_name');
- $this->_query->addWhere('a.user_id = ' . $this->file_owner);
- if ($qid =& $this->_query->exec())
+ }
+
+ $q = new DBQuery;
+ $q->addTable('users', 'a');
+ $q->leftJoin('contacts', 'b', 'b.contact_id = a.user_contact');
+ $q->addQuery('contact_first_name, contact_last_name');
+ $q->addWhere('a.user_id = ' . $this->file_owner);
+ if ($qid =& $q->exec()) {
$owner = $qid->fields['contact_first_name'] . ' ' . $qid->fields['contact_last_name'];
- $this->_query->clear();
+ }
+ $q->clear();
return $owner;
}
- function getTaskName()
- {
+ function getTaskName() {
$taskname = '';
- if (! $this->file_task)
+ if (! $this->file_task) {
return $taskname;
-
- $this->_query->clear();
- $this->_query->addTable('tasks');
- $this->_query->addQuery('task_name');
- $this->_query->addWhere('task_id = ' . $this->file_task);
+ }
+ $q = new DBQuery;
+ $q->addTable('tasks');
+ $q->addQuery('task_name');
+ $q->addWhere('task_id = ' . $this->file_task);
if ($qid =& $this->_query->exec()) {
- if ($qid->fields['task_name'])
- $taskname = $qid->fields['task_name'];
- else
- $taskname = $qid->fields[0];
+ $taskname = (($qid->fields['task_name']) ? $qid->fields['task_name'] : $qid->fields[0]);
}
- $this->_query->clear();
+ $q->clear();
return $taskname;
}
-
+
}
/**
@@ -523,191 +546,174 @@
var $file_folder_description = null;
function CFileFolder() {
- $this->CDpObject( 'file_folders', 'file_folder_id' );
+ $this->CDpObject('file_folders', 'file_folder_id');
}
- function getAllowedRecords($uid) {
- $q = new DBQuery();
- $q->addTable('file_folders');
- $q->addQuery('*');
- $q->addOrder('file_folder_parent');
- $q->addOrder('file_folder_name');
- return $q->loadHashList();
- }
-
- function getDeniedRecords($uid) {
- $q = new DBQuery();
- $q->addTable('file_folders');
- $q->addQuery('*');
- $q->addWhere('0=1');
- $q->addOrder('file_folder_parent');
- $q->addOrder('file_folder_name');
- return $q->loadHashList();
- }
-
function check() {
- $this->file_folder_id = intval( $this->file_folder_id );
- $this->file_folder_parent = intval( $this->file_folder_parent );
+ $this->file_folder_id = intval($this->file_folder_id);
+ $this->file_folder_parent = intval($this->file_folder_parent);
return null;
}
- function delete( $oid=null ) {
- $k = $this->_tbl_key;
- if ($oid) {
- $this->$k = intval( $oid );
- }
- if (!$this->canDelete( $msg, ($oid ? $oid : $this->file_folder_id) )) {
- return $msg;
- }
- $this->$k = $this->$k ? $this->$k : intval( ($oid ? $oid : $this->file_folder_id) );
-
- $q = new DBQuery();
- $q->setDelete($this->_tbl);
- $q->addWhere("{$this->_tbl_key} = {$this->$k}");
- $sql=$q->prepare();
- $q->clear();
-// $sql = "DELETE FROM $this->_tbl WHERE $this->_tbl_key = '".$this->$k."'";
- if (!db_exec( $sql )) {
- return db_error();
- } else {
- return NULL;
- }
+ function delete($oid=null) {
+ $oid = intval(($oid ? $oid : $this->file_folder_id));
+ return parent :: delete($oid);
}
- function canDelete(&$msg, $oid) {
+ function canDelete(&$msg, $oid=null, $joins=null) {
global $AppUI;
+
+ $oid = intval(($oid ? $oid : $this->file_folder_id));
+
+ if (!(parent::canDelete($msg, $oid, $joins))) {
+ return false;
+ }
+
$q = new DBQuery();
- $q->addTable('file_folders');
+ $q->addTable($this->_tbl);
$q->addQuery('COUNT(DISTINCT file_folder_id) AS num_of_subfolders');
- $q->addWhere("file_folder_parent=$oid");
+ $q->addWhere('file_folder_parent=' . $oid);
$sql1 = $q->prepare();
$q->clear();
-
+
$q = new DBQuery();
$q->addTable('files');
$q->addQuery('COUNT(DISTINCT file_id) AS num_of_files');
- $q->addWhere("file_folder=$oid");
+ $q->addWhere('file_folder=' . $oid);
$sql2 = $q->prepare();
$q->clear();
-// $sql = "SELECT COUNT(DISTINCT file_folder_id) AS num_of_subfolders FROM file_folders WHERE file_folder_parent = {$oid}";
+
if (db_loadResult($sql1) > 0 || db_loadResult($sql2) > 0) {
- $msg[] = 'File Folders';
- $msg = $AppUI->_( "Can't delete folder, it has files and/or subfolders." ) . ": " . implode( ', ', $msg );
- return false;
+ $msg = $AppUI->_('Can not delete folder, it has files and/or subfolders.');
+ return false;
}
- return true;
- //$joins[] = array('label'=>'Files','name'=>'files','idfield'=>'file_id','joinfield'=>'file_folder');
- //return parent::canDelete(&$msg, $oid, $joins );
+ return true;
}
/** @return string Returns the name of the parent folder or null if no parent was found **/
function getParentFolderName() {
$q = new DBQuery();
- $q->addTable('file_folders');
+ $q->addTable($this->_tbl);
$q->addQuery('file_folder_name');
- $q->addWhere("file_folder_id=$this->file_folder_parent");
+ $q->addWhere('file_folder_id=' . $this->file_folder_parent);
$sql = $q->prepare();
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the dPcommits
mailing list