X-Git-Url: https://scm.fusionforge.org/anonscm/gitweb?p=fusionforge%2Ffusionforge.git;a=blobdiff_plain;f=src%2Fcommon%2Fdocman%2FDocumentManager.class.php;h=a4c95a6e0a443615544f6889297bed4b132dec59;hp=a4625aef05506ba707bcf2496abaecf120bcf8f7;hb=fdacc913b8e0eb5e53bcf59253452966f5d8baf1;hpb=52430d8873ea04568050162756eecb03e85b9d7a diff --git a/src/common/docman/DocumentManager.class.php b/src/common/docman/DocumentManager.class.php index a4625aef05..a4c95a6e0a 100644 --- a/src/common/docman/DocumentManager.class.php +++ b/src/common/docman/DocumentManager.class.php @@ -3,6 +3,7 @@ * FusionForge document manager * * Copyright 2011-2012, Franck Villaume - TrivialDev + * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent * Copyright 2013, French Ministry of Education * http://fusionforge.org * @@ -48,7 +49,7 @@ class DocumentManager extends Error { * @param object The Group object to which this document is associated. * @return boolean success. */ - function DocumentManager(&$Group) { + function __construct(&$Group) { $this->Error(); if (!$Group || !is_object($Group)) { $this->setError('DocumentManager:: '. _('No Valid Group Object')); @@ -59,8 +60,6 @@ class DocumentManager extends Error { return false; } $this->Group =& $Group; - - return true; } /** @@ -109,8 +108,9 @@ class DocumentManager extends Error { $trashId = $this->getTrashID(); if ($trashId !== -1) { db_begin(); + $result = db_query_params('select docid FROM doc_data WHERE stateid=$1 and group_id=$2', array('2', $this->Group->getID())); $emptyFile = db_query_params('DELETE FROM doc_data WHERE stateid=$1 and group_id=$2', array('2', $this->Group->getID())); - if (!$emptyFile) { + if (!$emptyFile) { db_rollback(); return false; } @@ -119,6 +119,9 @@ class DocumentManager extends Error { db_rollback(); return false; } + while ($arr = db_fetch_array($result)) { + DocumentStorage::instance()->delete($arr['docid'])->commit(); + } db_commit(); return true; } @@ -272,6 +275,38 @@ class DocumentManager extends Error { } } + /** + * getActivity - return the number of searched actions per sections between two dates + * + * @param array Sections to search for activity + * @param int the start date time format time() + * @param int the end date time format time() + * @return array number per section of activities found between begin and end values + */ + function getActivity($sections, $begin, $end) { + $qpa = db_construct_qpa(false); + for ($i = 0; $i < count($sections); $i++) { + $union = 0; + if (count($sections) >= 1 && $i != count($sections) -1) { + $union = 1; + } + $qpa = db_construct_qpa($qpa, 'SELECT count(*) FROM activity_vw WHERE activity_date BETWEEN $1 AND $2 + AND group_id = $3 AND section = $4 ', + array($begin, + $end, + $this->getGroup()->getID(), + $sections[$i])); + if ($union) { + $qpa = db_construct_qpa($qpa, ' UNION ALL ', array()); + } + } + $res = db_query_qpa($qpa); + $results = array(); + $j = 0; + while ($arr = db_fetch_array($res)) { + $results[$sections[$j]] = $arr['0']; + $j++; + } + return $results; + } } - -?>