/**
  * Commentaires d'une procedure
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/01/30
  * @param object $rFiche Recordset de la procedure
  */
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $rFiche = $this->getParam('rFiche');
     $mondroit = $this->getParam('mondroit');
     $daoinfo =& _dao('infosupp');
     $sql = 'SELECT * FROM module_teleprocedure_infosupp WHERE idinter=' . $rFiche->idinter . '';
     $canCheckVisible = TeleproceduresService::canMakeInTelep('CHECK_VISIBLE', $mondroit);
     $canAddComment = TeleproceduresService::canMakeInTelep('ADD_COMMENT', $mondroit);
     if (!$canCheckVisible) {
         $sql .= " AND info_message!='' AND info_message IS NOT NULL";
     }
     $sql .= " ORDER BY dateinfo ASC, idinfo ASC";
     $results = _doQuery($sql);
     // Pour chaque message on cherche les infos de son auteur
     $list = array();
     foreach ($results as $r) {
         $userInfo = Kernel::getUserInfo("ID", $r->iduser);
         //var_dump($userInfo);
         $avatar = Prefs::get('prefs', 'avatar', $r->iduser);
         $userInfo['avatar'] = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         $r->user = $userInfo;
         $list[] = $r;
     }
     //print_r($rFiche);
     $tpl->assign('info_message_edition', CopixZone::process('kernel|edition', array('field' => 'info_message', 'format' => $rFiche->type_format, 'content' => '', 'width' => 350, 'height' => 135, 'options' => array('toolbarSet' => 'IconitoBasic', 'enterMode' => 'br', 'toolbarStartupExpanded' => 'false'))));
     $tpl->assign('info_commentaire_edition', CopixZone::process('kernel|edition', array('field' => 'info_commentaire', 'format' => $rFiche->type_format, 'content' => '', 'width' => 350, 'height' => 135, 'options' => array('toolbarSet' => 'IconitoBasic', 'enterMode' => 'br', 'toolbarStartupExpanded' => 'false'))));
     $tpl->assign('canCheckVisible', $canCheckVisible);
     $tpl->assign('canAddComment', $canAddComment);
     $tpl->assign('list', $list);
     $tpl->assign('rFiche', $rFiche);
     $toReturn = $tpl->fetch('fiche-comms-zone.tpl');
     return true;
 }
 /**
  * Affiche la fiche détaillée d'un utilisateur (login, nom, prénom...)
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/01/04
  * @param string $type Type de personne (USER_ELE, USER_ELE...)
  * @param integer $id Id
  */
 public function _createContent(&$toReturn)
 {
     $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService');
     $type = $this->getParam('type') ? $this->getParam('type') : NULL;
     $id = $this->getParam('id') ? $this->getParam('id') : NULL;
     $canWrite = $canView = false;
     if ($type && $id) {
         $usr = Kernel::getUserInfo($type, $id);
         $usr['type_nom'] = Kernel::Code2Name($usr['type']);
         //Kernel::myDebug($usr);
         $droits = Kernel::getUserInfoMatrix($usr);
         $canView = $droits['voir'];
         $canWrite = $droits['communiquer'];
         if ($canView) {
             // Avatar
             $avatar = '';
             if (isset($usr['user_id'])) {
                 $avatar = Prefs::get('prefs', 'avatar', $usr['user_id']);
             }
             $usr['avatar'] = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
             $parents = $enfants = array();
             if ($type == 'USER_ELE') {
                 // Pour un élève, on cherche ses parents
                 $parents = $annuaireService->getParentsFromEleve($id);
             } elseif ($type == 'USER_RES') {
                 // Pour un parent, on cherche ses enfants
                 $enfants = $annuaireService->getEnfantsFromParent($id);
             }
         } else {
             $usr = $parents = $enfants = false;
         }
         $tpl = new CopixTpl();
         $tpl->assign('usr', $usr);
         $tpl->assign('canWrite', $canWrite);
         $tpl->assign('parents', $parents);
         $tpl->assign('enfants', $enfants);
         $toReturn = $tpl->fetch('getuserprofilzone.tpl');
     }
     return true;
 }
예제 #3
0
 function execute()
 {
     if (Config::lpStoreRedis) {
         $key = get_class() . ':' . $this->typeID . ',' . $this->qty;
         $cache = json_decode($this->bpcCache->get($key), true);
         if (empty($cache) || empty($cache['manDetails']) || $cache['version'] != Db::$dbName) {
             $cache = array('version' => Db::$dbName, 'manDetails' => $this->performQuery());
             $this->bpcCache->set($key, json_encode($cache));
         }
     } else {
         $cache = array('version' => Db::$dbName, 'manDetails' => $this->performQuery());
     }
     # set price info for manufacturing materials
     foreach ($cache['manDetails'] as &$manItem) {
         try {
             $price = new Price(Emdr::get($manItem['typeID']));
             $manItem['price'] = $price->{Prefs::get('marketMat')}[0];
             $manItem['totPrice'] = $manItem['price'] * $manItem['totQty'];
         } catch (Exception $e) {
             array_push($this->noCache, $manItem['typeName']);
         }
     }
     return $cache['manDetails'];
 }
예제 #4
0
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 59 Temple Place - Suite 330                                          |
// | Boston, MA 02111-1307, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
//
// @(#) $Id$
//
include_once "config.inc.php";
include_once APP_INC_PATH . "class.template.php";
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.time_tracking.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("add_time_tracking.tpl.html");
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$issue_id = @$HTTP_POST_VARS["issue_id"] ? $HTTP_POST_VARS["issue_id"] : $HTTP_GET_VARS["iss_id"];
if (!Issue::canAccess($issue_id, Auth::getUserID())) {
    $tpl = new Template_API();
    $tpl->setTemplate("permission_denied.tpl.html");
    $tpl->displayTemplate();
    exit;
}
if (@$HTTP_POST_VARS["cat"] == "add_time") {
    $res = Time_Tracking::insertEntry();
    $tpl->assign("time_add_result", $res);
}
$tpl->assign(array("issue_id" => $issue_id, "time_categories" => Time_Tracking::getAssocCategories(), "current_user_prefs" => Prefs::get(Auth::getUserID())));
$tpl->displayTemplate();
예제 #5
0
$usr_id = Auth::getUserID();
$tpl = new Template_Helper();
$tpl->setTemplate('file_upload.tpl.html');
$issue_id = isset($_POST['issue_id']) ? $_POST['issue_id'] : $_GET['iss_id'];
$cat = isset($_POST['cat']) ? $_POST['cat'] : null;
// handle uploads
if ($cat == 'upload_file') {
    // attachment status (public or internal)
    $status = isset($_POST['status']) ? $_POST['status'] : null;
    $internal_only = $status == 'internal';
    // from ajax upload, attachment file ids
    $iaf_ids = !empty($_POST['iaf_ids']) ? explode(',', $_POST['iaf_ids']) : null;
    // description for attachments
    $file_description = isset($_POST['file_description']) ? $_POST['file_description'] : null;
    // if no iaf_ids passed, perhaps it's old style upload
    // TODO: verify that the uploaded file(s) owner is same as attachment owner.
    if (!$iaf_ids && isset($_FILES['attachment'])) {
        $iaf_ids = Attachment::addFiles($_FILES['attachment']);
    }
    try {
        Attachment::attachFiles($issue_id, $usr_id, $iaf_ids, $internal_only, $file_description);
        $res = 1;
    } catch (Exception $e) {
        error_log($e->getMessage());
        error_log($e->getTraceAsString());
        $res = -1;
    }
    $tpl->assign('upload_file_result', $res);
}
$tpl->assign(array('issue_id' => $issue_id, 'current_user_prefs' => Prefs::get(Auth::getUserID()), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'max_attachment_bytes' => Attachment::getMaxAttachmentSize(true)));
$tpl->displayTemplate();
예제 #6
0
    if (!@empty($HTTP_POST_VARS['new_status'])) {
        $res = Issue::setStatus($issue_id, $HTTP_POST_VARS['new_status']);
        if ($res != -1) {
            $new_status = Status::getStatusTitle($HTTP_POST_VARS['new_status']);
            History::add($issue_id, $usr_id, History::getTypeID('status_changed'), "Status changed to '{$new_status}' by " . User::getFullName($usr_id));
        }
    }
    $res = Note::insert($usr_id, $issue_id);
    $tpl->assign("post_result", $res);
    // enter the time tracking entry about this phone support entry
    if (!empty($HTTP_POST_VARS['time_spent'])) {
        $HTTP_POST_VARS['issue_id'] = $issue_id;
        $HTTP_POST_VARS['category'] = $HTTP_POST_VARS['time_category'];
        $HTTP_POST_VARS['summary'] = 'Time entry inserted when sending an internal note.';
        Time_Tracking::insertEntry();
    }
} elseif (@$HTTP_GET_VARS["cat"] == "reply") {
    if (!@empty($HTTP_GET_VARS["id"])) {
        $note = Note::getDetails($HTTP_GET_VARS["id"]);
        $date = Misc::formatReplyDate($note["timestamp"]);
        $header = "\n\n\nOn {$date}, " . $note["not_from"] . " wrote:\n>\n";
        $note["not_body"] = $header . Misc::formatReply($note["not_note"]);
        $tpl->bulkAssign(array("note" => $note, "parent_note_id" => $HTTP_GET_VARS["id"]));
        $reply_subject = Mail_API::removeExcessRe($note['not_title']);
    }
}
if (empty($reply_subject)) {
    $reply_subject = 'Re: ' . $details['iss_summary'];
}
$tpl->assign(array('from' => User::getFromHeader($usr_id), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'current_user_prefs' => Prefs::get($usr_id), 'subscribers' => Notification::getSubscribers($issue_id, false, User::getRoleID("Standard User")), 'statuses' => Status::getAssocStatusList($prj_id, false), 'current_issue_status' => Issue::getStatusID($issue_id), 'time_categories' => Time_Tracking::getAssocCategories(), 'note_category_id' => Time_Tracking::getCategoryID('Note Discussion'), 'reply_subject' => $reply_subject));
$tpl->displayTemplate();
예제 #7
0
 /**
  * Method used to send an email notification when an issue is
  * assigned to an user.
  *
  * @param   array $users The list of users
  * @param   integer $issue_id The issue ID
  */
 public static function notifyNewAssignment($users, $issue_id)
 {
     $prj_id = Issue::getProjectID($issue_id);
     $emails = array();
     foreach ($users as $usr_id) {
         if ($usr_id == Auth::getUserID()) {
             continue;
         }
         $prefs = Prefs::get($usr_id);
         if (!empty($prefs) && isset($prefs['receive_assigned_email'][$prj_id]) && $prefs['receive_assigned_email'][$prj_id] && $usr_id != Auth::getUserID()) {
             $emails[] = User::getFromHeader($usr_id);
         }
     }
     if (!$emails) {
         return;
     }
     // get issue details
     $issue = Issue::getDetails($issue_id);
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/assigned.tpl.text');
     $tpl->assign(array('app_title' => Misc::getToolCaption(), 'issue' => $issue, 'current_user' => User::getFullName(Auth::getUserID())));
     foreach ($emails as $email) {
         $text_message = $tpl->getTemplateContents();
         Language::set(User::getLang(User::getUserIDByEmail(Mail_Helper::getEmailAddress($email))));
         $subject = "[#{$issue_id}] New Assignment: " . $issue['iss_summary'];
         $from = self::getFixedFromHeader($issue_id, '', 'issue');
         // send email (use PEAR's classes)
         $mail = new Mail_Helper();
         $mail->setTextBody($text_message);
         $mail->setHeaders(Mail_Helper::getBaseThreadingHeaders($issue_id));
         $mail->send($from, $email, $subject, true, $issue_id, 'assignment');
     }
     Language::restore();
 }
예제 #8
0
        }
        $customer_id = Issue::getCustomerID($HTTP_GET_VARS['issue']);
        if (!empty($customer_id)) {
            $contact_emails = array_keys(Customer::getContactEmailAssocList($prj_id, $customer_id));
            $unknown_contacts = array();
            foreach ($sender_emails as $email => $address) {
                if (!@in_array($email, $contact_emails)) {
                    $usr_id = User::getUserIDByEmail($email);
                    if (empty($usr_id)) {
                        $unknown_contacts[] = $address;
                    } else {
                        // if we got a real user ID, check if the customer user is the correct one
                        // (i.e. a contact from the customer associated with the selected issue)
                        if (User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer')) {
                            // also check if the associated customer ID, if any, matches the one in the issue
                            $user_customer_id = User::getCustomerID($usr_id);
                            if ($user_customer_id != $customer_id) {
                                $unknown_contacts[] = $address;
                            }
                        }
                    }
                }
            }
            if (count($unknown_contacts) > 0) {
                $tpl->assign('unknown_contacts', $unknown_contacts);
            }
        }
    }
}
$tpl->assign("current_user_prefs", Prefs::get(Auth::getUserID()));
$tpl->displayTemplate();
예제 #9
0
파일: config.php 프로젝트: jelek92/lpStore
// comment this out for local debug copy
require_once 'Savant3.php';
# taken from http://stackoverflow.com/a/12583387/788054
# TBS cannot use DEFINE(), so these are variables
define('ABS_PATH', str_replace('\\', '/', dirname(__FILE__)) . '/');
define('BASE_PATH', '/' . substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])) . '/');
# to be deprecated - currently strongly discouraged in official documentation -gg
#function __autoload($class) {
#   require_once('lib/' . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php');
#}
# new style using spl_autoload_register:
spl_autoload_register(function ($class) {
    require_once 'lib/' . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
});
Emdr::$regions = json_decode(file_get_contents(ABS_PATH . '/emdr/regions.json'), true);
Prefs::getInstance();
$tpl = new Savant3();
$tpl->addPath('template', 'templates/bootstrap');
$tpl->addPath('resource', 'lib');
$tpl->siteTime = new Timer();
$tpl->emdrDown = false;
# https://forums.eveonline.com/default.aspx?g=posts&m=2508255
$regions = json_decode(file_get_contents(dirname(__FILE__) . '/emdr/regions.json'), true);
Emdr::setRegion(Prefs::get('region'));
# If price of Tritanium is more than 12 hours old, then something has happened with EMDR consumer
# Set template variable to display warning to user when this happens
if (time() - (new Price(Emdr::get(34)))->generatedAt > 60 * 60 * 12) {
    $tpl->emdrDown = true;
}
$tpl->webkitFix = preg_match("#.+WebKit/(\\H+)+\\s.+?#s", $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 535 ? true : false;
예제 #10
0
파일: LpOffer.php 프로젝트: jelek92/lpStore
 private function bpcCalc()
 {
     if (!$this->bpc) {
         return;
     }
     # Something's gone wrong, don't do this if not a BPC
     # Do this in template
     // $name =  "1 x ".$offer['typeName']." Copy (".$offer['quantity']." run".($offer['quantity'] > 1 ? "s" : null).")";
     $this->manTypeID = Db::qColumn('
         SELECT `productTypeID`
         FROM `industryActivityProducts`
         WHERE `typeID` = :typeID
         AND `activityID` = 1', array(':typeID' => $this->offerDetails['typeID']));
     # set pricing info per the manufactured item
     try {
         $price = new Price(Emdr::get($this->manTypeID));
         $this->cached = true;
         $this->price = $price->{Prefs::get('marketOffer')}[0];
         $this->totVolume = $price->{Prefs::get('marketOffer')}[1];
         $this->timeDiff = (time() - $price->generatedAt) / 60 / 60;
         # time difference in hours
     } catch (Exception $e) {
         array_push($this->noCache, $this->offerDetails['typeName']);
     }
     # find cached result of BPC manufacturing materials
     $this->manDetails = (new Query_OfferMaterials($this->offerDetails['typeID'], $this->offerDetails['quantity']))->execute();
     # set market group to BPs (doesn't happen automatically since you can't find LP Store BPs on market)
     $this->offerDetails['marketRoot'] = '2';
 }
예제 #11
0
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
// | GNU General Public License for more details.                         |
// |                                                                      |
// | You should have received a copy of the GNU General Public License    |
// | along with this program; if not, write to:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                          |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('add_phone_entry.tpl.html');
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$issue_id = @$_POST['issue_id'] ? $_POST['issue_id'] : $_GET['iss_id'];
if (!Issue::canAccess($issue_id, Auth::getUserID()) || Auth::getCurrentRole() <= User::getRoleID('Customer')) {
    $tpl = new Template_Helper();
    $tpl->setTemplate('permission_denied.tpl.html');
    $tpl->displayTemplate();
    exit;
}
if (@$_POST['cat'] == 'add_phone') {
    $res = Phone_Support::insert();
    $tpl->assign('add_phone_result', $res);
}
$prj_id = Issue::getProjectID($issue_id);
$usr_id = Auth::getUserID();
$tpl->assign(array('issue_id' => $issue_id, 'phone_categories' => Phone_Support::getCategoryAssocList($prj_id), 'current_user_prefs' => Prefs::get($usr_id)));
$tpl->displayTemplate();
예제 #12
0
 /**
  * Processes the template and assign common variables automatically.
  * @return $this
  */
 private function processTemplate()
 {
     $core = array('rel_url' => APP_RELATIVE_URL, 'base_url' => APP_BASE_URL, 'app_title' => APP_NAME, 'app_version' => APP_VERSION, 'app_setup' => Setup::load(), 'messages' => Misc::getMessages(), 'roles' => User::getAssocRoleIDs(), 'auth_backend' => APP_AUTH_BACKEND, 'current_url' => $_SERVER['PHP_SELF']);
     // If VCS version is present "Eventum 2.3.3-148-g78b3368", link ref to github
     $vcsVersion = self::getVcsVersion();
     if ($vcsVersion) {
         $link = "https://github.com/eventum/eventum/commit/{$vcsVersion}";
         $core['application_version_link'] = $link;
         // append VCS version if not yet there
         if (!preg_match('/-g[0-9a-f]+$/', APP_VERSION)) {
             $core['app_version'] = "v{$core['app_version']}-g{$vcsVersion}";
         }
     }
     $usr_id = Auth::getUserID();
     if ($usr_id) {
         $core['user'] = User::getDetails($usr_id);
         $prj_id = Auth::getCurrentProject();
         $setup = Setup::load();
         if (!empty($prj_id)) {
             $role_id = User::getRoleByUser($usr_id, $prj_id);
             $has_crm = CRM::hasCustomerIntegration($prj_id);
             $core = $core + array('project_id' => $prj_id, 'project_name' => Auth::getCurrentProjectName(), 'has_crm' => $has_crm, 'current_role' => $role_id, 'current_role_name' => User::getRole($role_id), 'feature_access' => Access::getFeatureAccessArray($usr_id));
             if ($has_crm) {
                 $crm = CRM::getInstance($prj_id);
                 $core['crm_template_path'] = $crm->getTemplatePath();
                 if ($role_id == User::getRoleID('Customer')) {
                     try {
                         $contact = $crm->getContact($core['user']['usr_customer_contact_id']);
                         $core['allowed_customers'] = $contact->getCustomers();
                         $core['current_customer'] = $crm->getCustomer(Auth::getCurrentCustomerID(false));
                     } catch (CRMException $e) {
                     }
                 }
             }
         }
         $info = User::getDetails($usr_id);
         $raw_projects = Project::getAssocList(Auth::getUserID(), false, true);
         $active_projects = array();
         foreach ($raw_projects as $prj_id => $prj_info) {
             if ($prj_info['status'] == 'archived') {
                 $prj_info['prj_title'] .= ' ' . ev_gettext('(archived)');
             }
             $active_projects[$prj_id] = $prj_info['prj_title'];
         }
         $core = $core + array('active_projects' => $active_projects, 'current_full_name' => $info['usr_full_name'], 'current_email' => $info['usr_email'], 'current_user_id' => $usr_id, 'current_user_datetime' => Date_Helper::getISO8601date('now', '', true), 'is_current_user_clocked_in' => User::isCLockedIn($usr_id), 'is_anon_user' => Auth::isAnonUser(), 'is_current_user_partner' => !empty($info['usr_par_code']), 'roles' => User::getAssocRoleIDs(), 'current_user_prefs' => Prefs::get(Auth::getUserID()));
         $this->assign('current_full_name', $core['user']['usr_full_name']);
         $this->assign('current_email', $core['user']['usr_email']);
         $this->assign('current_user_id', $usr_id);
         $this->assign('handle_clock_in', $setup['handle_clock_in'] == 'enabled');
         $this->assign('is_current_user_clocked_in', User::isClockedIn($usr_id));
         $this->assign('roles', User::getAssocRoleIDs());
     }
     $this->assign('core', $core);
     return $this;
 }
예제 #13
0
    $tpl->assign("delete_phone_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "new_status") {
    // XXX: need to call the workflow api in the following function?
    $res = Issue::setStatus($HTTP_GET_VARS["iss_id"], $HTTP_GET_VARS["new_sta_id"], true);
    if ($res == 1) {
        History::add($HTTP_GET_VARS["iss_id"], $usr_id, History::getTypeID('status_changed'), "Issue manually set to status '" . Status::getStatusTitle($HTTP_GET_VARS["new_sta_id"]) . "' by " . User::getFullName($usr_id));
    }
    $tpl->assign("new_status_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "new_category") {
    $res = Issue::setCategory($HTTP_GET_VARS["iss_id"], $HTTP_GET_VARS["iss_prc_id"], true);
    if ($res == 1) {
        History::add($HTTP_GET_VARS["iss_id"], $usr_id, History::getTypeID('status_changed'), "Issue manually set to category '" . Category::getTitle($HTTP_GET_VARS["iss_prc_id"]) . "' by " . User::getFullName($usr_id));
    }
    $tpl->assign("new_status_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "new_project") {
    $res = Issue::setProject($HTTP_GET_VARS["iss_id"], $HTTP_GET_VARS["iss_prj_id"], true);
    if ($res == 1) {
        History::add($HTTP_GET_VARS["iss_id"], $usr_id, History::getTypeID('status_changed'), "Issue manually set to project '" . Project::getName($HTTP_GET_VARS["iss_prj_id"]) . "' by " . User::getFullName($usr_id));
    }
    $tpl->assign("new_status_result", $res);
} elseif (@$HTTP_GET_VARS['cat'] == 'authorize_reply') {
    $res = Authorized_Replier::addUser($HTTP_GET_VARS["iss_id"], $usr_id);
    $tpl->assign('authorize_reply_result', $res);
} elseif (@$HTTP_GET_VARS['cat'] == 'remove_quarantine') {
    if (Auth::getCurrentRole() > User::getRoleID('Developer')) {
        $res = Issue::setQuarantine($HTTP_GET_VARS['iss_id'], 0);
        $tpl->assign('remove_quarantine_result', $res);
    }
}
$tpl->assign("current_user_prefs", Prefs::get($usr_id));
$tpl->displayTemplate();
예제 #14
0
 /**
  * Returns the data used by the weekly report.
  *
  * @access  public
  * @param   string $usr_id The ID of the user this report is for.
  * @param   string The start date of this report.
  * @param   string The end date of this report.
  * @param   boolean If closed issues should be separated from other issues.
  * @return  array An array of data containing all the elements of the weekly report.
  */
 function getWeeklyReport($usr_id, $start, $end, $separate_closed = false)
 {
     $usr_id = Misc::escapeInteger($usr_id);
     // figure out timezone
     $user_prefs = Prefs::get($usr_id);
     $tz = @$user_prefs["timezone"];
     $start_dt = new Date();
     $end_dt = new Date();
     // set timezone to that of user.
     $start_dt->setTZById($tz);
     $end_dt->setTZById($tz);
     // set the dates in the users time zone
     $start_dt->setDate($start . " 00:00:00");
     $end_dt->setDate($end . " 23:59:59");
     // convert time to GMT
     $start_dt->toUTC();
     $end_dt->toUTC();
     $start_ts = $start_dt->getDate();
     $end_ts = $end_dt->getDate();
     $time_tracking = Time_Tracking::getSummaryByUser($usr_id, $start_ts, $end_ts);
     // replace spaces in index with _ and calculate total time
     $total_time = 0;
     foreach ($time_tracking as $category => $data) {
         unset($time_tracking[$category]);
         $time_tracking[str_replace(" ", "_", $category)] = $data;
         $total_time += $data["total_time"];
     }
     // get count of issues assigned in week of report.
     $stmt = "SELECT\n                    COUNT(*)\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n                 WHERE\n                    iss_id = isu_iss_id AND\n                    iss_sta_id = sta_id AND\n                    isu_usr_id = {$usr_id} AND\n                    isu_assigned_date BETWEEN '{$start_ts}' AND '{$end_ts}'";
     $newly_assigned = $GLOBALS["db_api"]->dbh->getOne($stmt);
     if (PEAR::isError($newly_assigned)) {
         Error_Handler::logError(array($newly_assigned->getMessage(), $newly_assigned->getDebugInfo()), __FILE__, __LINE__);
     }
     $email_count = array("associated" => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, true), "other" => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, false));
     $data = array("start" => str_replace('-', '.', $start), "end" => str_replace('-', '.', $end), "user" => User::getDetails($usr_id), "group_name" => Group::getName(User::getGroupID($usr_id)), "issues" => History::getTouchedIssuesByUser($usr_id, $start_ts, $end_ts, $separate_closed), "status_counts" => History::getTouchedIssueCountByStatus($usr_id, $start_ts, $end_ts), "new_assigned_count" => $newly_assigned, "time_tracking" => $time_tracking, "email_count" => $email_count, "phone_count" => Phone_Support::getCountByUser($usr_id, $start_ts, $end_ts), "note_count" => Note::getCountByUser($usr_id, $start_ts, $end_ts), "total_time" => Misc::getFormattedTime($total_time, false));
     return $data;
 }
 /**
  * Affiche une discussion d'un cahier de correspondance
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/16
  * @param integer $id Id de la discussion
  * @param integer $eleve (option) Id de l'élève
  * @param integer $print (option, 0 par défaut) Si 1, affiche la discussion au format imprimable
  * @param string $go (option) Si vaut "new", redirige sur le premier message non lu de la discussion
  */
 public function getTopic()
 {
     $dao = CopixDAOFactory::create("carnet_topics");
     $kernel_service =& CopixClassesFactory::Create('kernel|kernel');
     $carnet_service =& CopixClassesFactory::Create('carnet|CarnetService');
     $id = $this->getRequest('id', null);
     $eleve = $this->getRequest('eleve', null);
     $print = $this->getRequest('print', 0);
     $go = $this->getRequest('go', null);
     $session = Kernel::getSessionBU();
     $criticErrors = array();
     if ($go == "new") {
         $daoTracking = CopixDAOFactory::create("carnet|carnet_tracking2");
         if ($eleve && $eleve != 'CLASSE') {
             $idEleves = array($eleve);
         } else {
             $to = $dao->getElevesForTopic($id);
             $idEleves = array();
             foreach ($to as $item) {
                 $idEleves[] = $item->eleve;
             }
         }
         //print_r($idEleves);
         //die();
         $unread = $daoTracking->getFirstUnreadMessage($id, $session['user_id'], $idEleves);
         //_dump($unread[0]);
         if ($unread[0]->id) {
             // Il est déjà passé dans le topic
             $urlReturn = CopixUrl::get('|getTopic', array('id' => $id, 'eleve' => $eleve)) . '#m' . $unread[0]->id;
         } else {
             // Jamais passé, on le renvoie au début du topic
             $urlReturn = CopixUrl::get('|getTopic', array('id' => $id, 'eleve' => $eleve));
         }
         //die($urlReturn);
         return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
     }
     $topic = $dao->get($id);
     $classe = $topic->classe;
     $ppo = new CopixPPO();
     if (!$topic) {
         $criticErrors[] = CopixI18N::get('carnet|carnet.error.noTopic');
     }
     $matrix =& enic::get('matrixCache');
     $ppo->canView_USER_RES = $matrix->classe($classe)->_right->USER_RES->voir;
     $ppo->canView_USER_ENS = $matrix->classe($classe)->_right->USER_ENS->voir;
     $ppo->canView_USER_ELE = $matrix->classe($classe)->_right->USER_ELE->voir;
     //_dump($canWrite_USER_RES);
     $mondroit = $carnet_service->getUserDroitInCarnet(array("classe" => $classe, "eleve" => $eleve));
     //print_r("mondroit=$mondroit");
     if (!$mondroit) {
         $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('carnet||getCarnet', array())));
     }
     if (0) {
     } else {
         //			print_r2($topic);
         // 1. Infos sur le topic
         $userInfo = $kernel_service->getUserInfo("ID", $topic->createur);
         $topic->createur_nom = $userInfo["prenom"] . " " . $userInfo["nom"];
         $topic->createur_infos = $userInfo;
         $to = $dao->getElevesForTopic($topic->id);
         while (list($k, ) = each($to)) {
             $userInfo = $kernel_service->getUserInfo("USER_ELE", $to[$k]->eleve);
             $to[$k]->eleve_infos = $userInfo["prenom"] . " " . $userInfo["nom"];
         }
         $topic->eleves = $to;
         $topic->nb_eleves = count($to);
         // Avatar de l'auteur
         $avatar = Prefs::get('prefs', 'avatar', $topic->createur);
         $topic->avatar = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         //print_r2($topic);
         // 2. Les messages
         if ($eleve && $eleve != 'CLASSE') {
             // Filtrage sur un élève
             $list = $dao->getListCarnetsMessagesForTopicAndEleve($id, $eleve);
             $idEleves = array($eleve);
         } else {
             // Tous les élèves de la classe
             $eleves = $carnet_service->getUserElevesInClasse($topic->classe);
             $list = $dao->getListCarnetsMessagesForTopicAndEleves($id, $eleves);
             //print_r($list);
             $idEleves = array();
             foreach ($to as $item) {
                 $idEleves[] = $item->eleve;
             }
         }
         //print_r($idEleves);
         while (list($k, ) = each($list)) {
             $userInfo = $kernel_service->getUserInfo("ID", $list[$k]->auteur);
             $list[$k]->auteur_nom = $userInfo["prenom"] . " " . $userInfo["nom"];
             $list[$k]->auteur_infos = $userInfo;
             $userInfo = $kernel_service->getUserInfo("USER_ELE", $list[$k]->eleve);
             $list[$k]->eleve_nom = $userInfo["prenom"] . " " . $userInfo["nom"];
             $list[$k]->eleve_infos = $userInfo;
             // Avatar de l'expéditeur
             $avatar = Prefs::get('prefs', 'avatar', $list[$k]->auteur);
             $list[$k]->avatar = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         }
         $canWriteClasse = $carnet_service->canMakeInCarnet('WRITE_CLASSE', NULL);
         $canPrintTopic = $carnet_service->canMakeInCarnet('PRINT_TOPIC', NULL);
         // On enregistre sa lecture (tracking)
         $carnet_service->userReadTopic($id, $session['user_id'], $idEleves);
         CopixHTMLHeader::addCSSLink(_resource("styles/module_carnet.css"));
         if ($print) {
             CopixHTMLHeader::addCSSLink(_resource("styles/module_carnet_print.css"), array('media' => 'print'));
         }
         $tpl = new CopixTpl();
         $tpl->assign('TITLE_PAGE', $topic->titre);
         //$tpl->assign ('MENU', '<a href="'.CopixUrl::get ('carnet||getCarnet', array("classe"=>$classe, "eleve"=>$eleve)).'">'.CopixI18N::get ('carnet|carnet.backCarnet').'</a>');
         //print_r($list);
         //print_r($topic);
         $tplListe = new CopixTpl();
         $tplListe->assign('ppo', $ppo);
         $tplListe->assign('topic', $topic);
         $tplListe->assign('eleve', $eleve);
         $tplListe->assign('canWriteClasse', $canWriteClasse);
         $tplListe->assign('canPrintTopic', $canPrintTopic);
         $tplListe->assign('list', $list);
         $tplListe->assign('session', Kernel::getSessionBU());
         $tplListe->assign('linkClasse', CopixUrl::get('carnet||getTopic', array('id' => $topic->id)));
         if ($print) {
             $result = $tplListe->fetch("gettopicprint.tpl");
         } else {
             $result = $tplListe->fetch("gettopic.tpl");
         }
         $tpl->assign("MAIN", $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
예제 #16
0
// | along with this program; if not, write to:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                          |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$prj_id = Auth::getCurrentProject();
$usr_id = Auth::getUserID();
$role_id = Auth::getCurrentRole();
$associated_projects = @array_keys(Project::getAssocList($usr_id));
$tpl = new Template_Helper();
$tpl->setTemplate('update.tpl.html');
$tpl->assign('user_prefs', Prefs::get($usr_id));
Auth::checkAuthentication(APP_COOKIE);
$issue_id = @$_POST['issue_id'] ? $_POST['issue_id'] : @$_GET['id'];
$tpl->assign('issue_id', $issue_id);
$details = Issue::getDetails($issue_id);
if ($details == '') {
    Misc::setMessage(ev_gettext('Error: The issue #%1$s could not be found.', $issue_id), Misc::MSG_ERROR);
    $tpl->displayTemplate();
    exit;
}
Workflow::prePage($prj_id, 'update');
// check if the requested issue is a part of the 'current' project. If it doesn't
// check if issue exists in another project and if it does, switch projects
$iss_prj_id = Issue::getProjectID($issue_id);
$auto_switched_from = false;
if (!empty($iss_prj_id) && $iss_prj_id != $prj_id && in_array($iss_prj_id, $associated_projects)) {
예제 #17
0
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('emails.tpl.html');
Auth::checkAuthentication(APP_COOKIE);
if (!Access::canAccessAssociateEmails(Auth::getUserID())) {
    $tpl->assign('no_access', 1);
    $tpl->displayTemplate();
    exit;
}
$pagerRow = Support::getParam('pagerRow');
if (empty($pagerRow)) {
    $pagerRow = 0;
}
$rows = Support::getParam('rows');
if (empty($rows)) {
    $rows = APP_DEFAULT_PAGER_SIZE;
}
$options = Support::saveSearchParams();
$tpl->assign('options', $options);
$tpl->assign('sorting', Support::getSortingInfo($options));
$list = Support::getEmailListing($options, $pagerRow, $rows);
$tpl->assign('list', $list['list']);
$tpl->assign('list_info', $list['info']);
$tpl->assign('issues', Issue::getColList());
$tpl->assign('accounts', Email_Account::getAssocList(Auth::getCurrentProject()));
$prefs = Prefs::get(Auth::getUserID());
$tpl->assign('refresh_rate', $prefs['email_refresh_rate'] * 60);
$tpl->assign('refresh_page', 'emails.php');
$tpl->displayTemplate();
예제 #18
0
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                        |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// | Authors: Elan Ruusamäe <*****@*****.**>                               |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('add_time_tracking.tpl.html');
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$issue_id = @$_POST['issue_id'] ? $_POST['issue_id'] : $_GET['iss_id'];
if (!Issue::canAccess($issue_id, Auth::getUserID()) || Auth::getCurrentRole() <= User::getRoleID('Customer')) {
    $tpl = new Template_Helper();
    $tpl->setTemplate('permission_denied.tpl.html');
    $tpl->displayTemplate();
    exit;
}
if (@$_POST['cat'] == 'add_time') {
    $date = (array) $_POST['date'];
    $ttc_id = (int) $_POST['category'];
    $iss_id = (int) $_POST['issue_id'];
    $time_spent = (int) $_POST['time_spent'];
    $summary = (string) $_POST['summary'];
    $res = Time_Tracking::addTimeEntry($iss_id, $ttc_id, $time_spent, $date, $summary);
    $tpl->assign('time_add_result', $res);
}
$prj_id = Auth::getCurrentProject();
$tpl->assign(array('issue_id' => $issue_id, 'time_categories' => Time_Tracking::getAssocCategories($prj_id), 'current_user_prefs' => Prefs::get(Auth::getUserID())));
$tpl->displayTemplate();
예제 #19
0
 /**
  * Method used to get the timezone preferred by the user.
  *
  * @param integer $usr_id The user ID
  * @return string The timezone preferred by the user
  */
 public static function getPreferredTimezone($usr_id = null)
 {
     if (!$usr_id) {
         $usr_id = Auth::getUserID();
     }
     if (!$usr_id) {
         return self::getDefaultTimezone();
     }
     $prefs = Prefs::get($usr_id);
     if (!empty($prefs['timezone'])) {
         return $prefs['timezone'];
     }
     return self::getDefaultTimezone();
 }
 /**
  * Affiche un minimail en d�tail
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/10/18
  * @param integer $id Id du minimail
  */
 public function getMessage()
 {
     $this->addJs('js/iconito/module_minimail.js');
     $MinimailService =& CopixClassesFactory::Create('minimail|MinimailService');
     // 2 DAO -> 2 assign
     $idUser = _currentUser()->getId();
     $idMessage = _request("id");
     $errors = array();
     $daoFrom = CopixDAOFactory::create("minimail_from");
     $daoTo = CopixDAOFactory::create("minimail_to");
     $message = $daoFrom->getMessage($idMessage);
     $dest = $daoTo->selectDestFromId($idMessage);
     $isRecv = $isSend = false;
     if ($message) {
         $message->prev = NULL;
         $message->next = NULL;
     }
     if ($message && $message->from_id == $idUser) {
         // Message qu'il a envoy�
         $message->type = "send";
         $prev = $daoFrom->getFromPrevMessage($message->date_send, $idUser);
         if ($prev) {
             $message->prev = $prev->id;
         }
         $next = $daoFrom->getFromNextMessage($message->date_send, $idUser);
         if ($next) {
             $message->next = $next->id;
         }
         $isSend = true;
     } else {
         // Il en est peut-�tre destinataire
         $isDest = $daoTo->selectDestFromIdAndToUser($idMessage, $idUser);
         // Test s'il est dans les destin
         if ($isDest) {
             $serv = CopixClassesFactory::create("MinimailService");
             $serv->markMinimailAsRead($dest, $idUser);
             $message->type = "recv";
             $prev = $daoTo->getToPrevMessage($message->date_send, $idUser);
             if ($prev) {
                 $message->prev = $prev->id;
             }
             $next = $daoTo->getToNextMessage($message->date_send, $idUser);
             if ($next) {
                 $message->next = $next->id;
             }
             $isRecv = true;
         } else {
             // Il tente d'afficher un message qu'il n'a pas envoy� ni re�u !
             $errors[] = CopixI18N::get('minimail.error.cantDisplay');
         }
     }
     if ($errors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('minimail||')));
     } else {
         $userInfo = Kernel::getUserInfo("ID", $message->from_id);
         $message->from = $userInfo;
         $message->from_id_infos = $userInfo["prenom"] . " " . $userInfo["nom"] . " (" . $userInfo["login"] . ")";
         foreach ($dest as $j => $null) {
             //print_r($dest[$j]->to_id);
             $userInfo = Kernel::getUserInfo("ID", $dest[$j]->to_id);
             $dest[$j]->to = $userInfo;
             $dest[$j]->to_id_infos = $userInfo["prenom"] . " " . $userInfo["nom"] . " (" . $userInfo["login"] . ")";
         }
         // Avatar de l'exp�diteur
         $avatar = Prefs::get('prefs', 'avatar', $message->from_id);
         $message->avatar = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         $tpl = new CopixTpl();
         $tpl->assign('TITLE_PAGE', $message->title);
         $menu = array();
         $menu[] = array('txt' => CopixI18N::get('minimail.mess_recv'), 'url' => CopixUrl::get('minimail||getListRecv'), 'current' => $isRecv);
         $menu[] = array('txt' => CopixI18N::get('minimail.mess_send'), 'url' => CopixUrl::get('minimail||getListSend'), 'current' => $isSend);
         $menu[] = array('txt' => CopixI18N::get('minimail.mess_write'), 'url' => CopixUrl::get('minimail||getNewForm'));
         $tpl->assign('MENU', $menu);
         $message->attachment1IsImage = $MinimailService->isAttachmentImage($message->attachment1);
         $message->attachment2IsImage = $MinimailService->isAttachmentImage($message->attachment2);
         $message->attachment3IsImage = $MinimailService->isAttachmentImage($message->attachment3);
         $message->attachment1Name = $MinimailService->getAttachmentName($message->attachment1);
         $message->attachment2Name = $MinimailService->getAttachmentName($message->attachment2);
         $message->attachment3Name = $MinimailService->getAttachmentName($message->attachment3);
         //print_r($message);
         $tplListe = new CopixTpl();
         $tplListe->assign('message', $message);
         $tplListe->assign('dest', $dest);
         $result = $tplListe->fetch('getmessage.tpl');
         $tpl->assign('MAIN', $result);
         $plugStats = CopixPluginRegistry::get("stats|stats");
         $plugStats->setParams(array('objet_a' => $idMessage));
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
예제 #21
0
<?php

if (is_numeric($data->req_id)) {
    $prefs = new Prefs();
    $pref_data = $prefs->get($data->req_id, "uid");
    $GLOBALS['hooks']['auth']['prefs'] = $pref_data;
    unset($prefs);
    unset($pref_data);
} else {
    $GLOBALS['hooks']['auth']['prefs']->fname = "";
    $GLOBALS['hooks']['auth']['prefs']->lname = "";
}
예제 #22
0
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
// | GNU General Public License for more details.                         |
// |                                                                      |
// | You should have received a copy of the GNU General Public License    |
// | along with this program; if not, write to:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                          |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: Bryan Alsdorf <*****@*****.**>                             |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('reports/workload_time_period.tpl.html');
Auth::checkAuthentication(APP_COOKIE);
$usr_id = Auth::getUserID();
if (!Access::canAccessReports(Auth::getUserID())) {
    echo 'Invalid role';
    exit;
}
$prj_id = Auth::getCurrentProject();
// get timezone of current user
$user_prefs = Prefs::get($usr_id);
if (@$_GET['type'] == 'email') {
    $data = Report::getEmailWorkloadByTimePeriod(@$user_prefs['timezone']);
} else {
    $data = Report::getWorkloadByTimePeriod(@$user_prefs['timezone']);
}
$tpl->assign(array('data' => $data, 'type' => @$_GET['type'], 'user_tz' => Date_Helper::getTimezoneShortNameByUser($usr_id)));
$tpl->displayTemplate();
예제 #23
0
 /**
  * Generates the workload by time period graph.
  *
  * @param string $type
  */
 public function WorkloadTimePeriodGraph($type)
 {
     $usr_id = Auth::getUserID();
     // get timezone of current user
     $user_prefs = Prefs::get($usr_id);
     if ($type == 'email') {
         $data = Report::getEmailWorkloadByTimePeriod($user_prefs['timezone'], true);
         $graph_title = ev_gettext('Email by Time Period');
         $event_type = ev_gettext('emails');
     } else {
         $data = Report::getWorkloadByTimePeriod($user_prefs['timezone'], true);
         $graph_title = ev_gettext('Workload by Time Period');
         $event_type = ev_gettext('actions');
     }
     // TRANSLATORS: %s = Timezone name
     $xtitle = ev_gettext('Hours (%s)', Date_Helper::getTimezoneShortNameByUser($usr_id));
     // rebuild data for phplot format
     $plotData = array();
     $legends = array();
     $i = 1;
     foreach ($data as $performer => $values) {
         foreach ($values as $hour => $value) {
             $plotData[(int) $hour][0] = $hour;
             $plotData[(int) $hour][$i] = $value;
         }
         $legends[$i] = ucfirst($performer) . ' ' . $event_type;
         $i++;
     }
     $plot = $this->create(900, 350);
     $plot->SetImageBorderType('plain');
     $plot->SetPlotType('bars');
     $plot->SetDataType('text-data');
     $plot->SetDataValues($plotData);
     $plot->SetTitle($graph_title);
     $plot->SetLegend($legends);
     $plot->SetYTitle($event_type);
     $plot->SetXTitle($xtitle);
     $plot->SetXTickLabelPos('none');
     $plot->SetXTickPos('none');
     $plot->SetYDataLabelPos('plotin');
     $plot->SetYLabelType('printf', '%.0f%%');
     $plot->group_frac_width = 1;
     $plot->DrawGraph();
 }
예제 #24
0
 /**
  * Retrieves the list of users, round robin blackout hours and their
  * respective preferences with regards to timezones.
  *
  * @param   integer $prj_id The project ID
  * @return  array The list of users
  */
 public function getUsersByProject($prj_id)
 {
     $stmt = 'SELECT
                 usr_id,
                 rru_next,
                 prr_blackout_start,
                 prr_blackout_end
              FROM
                 {{%project_round_robin}},
                 {{%round_robin_user}},
                 {{%user}}
              WHERE
                 prr_prj_id=? AND
                 prr_id=rru_prr_id AND
                 rru_usr_id=usr_id
              ORDER BY
                 usr_id ASC';
     try {
         $res = DB_Helper::getInstance()->getAll($stmt, array($prj_id));
     } catch (DbException $e) {
         return array();
     }
     $blackout_start = '';
     $blackout_end = '';
     $t = array();
     foreach ($res as $row) {
         $blackout_start = $row['prr_blackout_start'];
         $blackout_end = $row['prr_blackout_end'];
         $prefs = Prefs::get($row['usr_id']);
         $t[$row['usr_id']] = array('timezone' => $prefs['timezone'], 'is_next' => $row['rru_next']);
     }
     return array($blackout_start, $blackout_end, $t);
 }
예제 #25
0
파일: new.php 프로젝트: korusdipl/eventum
            $email_details = Support::getEmailDetails(Email_Account::getAccountByEmail($item[0]), $item[0]);
            $tpl->assign(array('issue_summary' => $email_details['sup_subject'], 'issue_description' => $email_details['seb_body']));
            // also auto pre-fill the customer contact text fields
            if (CRM::hasCustomerIntegration($prj_id)) {
                $sender_email = Mail_Helper::getEmailAddress($email_details['sup_from']);
                try {
                    $contact = $crm->getContactByEmail($sender_email);
                    $tpl->assign('contact_details', $contact->getDetails());
                } catch (CRMException $e) {
                }
            }
        }
    }
}
$tpl->assign(array('cats' => Category::getAssocList($prj_id), 'priorities' => Priority::getAssocList($prj_id), 'severities' => Severity::getList($prj_id), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'releases' => Release::getAssocList($prj_id), 'custom_fields' => Custom_Field::getListByProject($prj_id, 'report_form'), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'max_attachment_bytes' => Attachment::getMaxAttachmentSize(true), 'field_display_settings' => Project::getFieldDisplaySettings($prj_id), 'groups' => Group::getAssocList($prj_id), 'products' => Product::getList(false)));
$prefs = Prefs::get($usr_id);
$tpl->assign('user_prefs', $prefs);
$tpl->assign('zones', Date_Helper::getTimezoneList());
if (Auth::getCurrentRole() == User::getRoleID('Customer')) {
    $crm = CRM::getInstance(Auth::getCurrentProject());
    $customer_contact_id = User::getCustomerContactID($usr_id);
    $contact = $crm->getContact($customer_contact_id);
    $customer_id = Auth::getCurrentCustomerID();
    $customer = $crm->getCustomer($customer_id);
    // TODOCRM: Pull contacts via ajax when user selects contract
    $tpl->assign(array('customer_id' => $customer_id, 'contact_id' => $customer_contact_id, 'customer' => $customer, 'contact' => $contact));
}
$clone_iss_id = isset($_GET['clone_iss_id']) ? (int) $_GET['clone_iss_id'] : null;
if ($clone_iss_id && Access::canCloneIssue($clone_iss_id, $usr_id)) {
    $tpl->assign(Issue::getCloneIssueTemplateVariables($clone_iss_id));
} else {
 /**
  * Affichage d'une discussion (ses messages)
  *
  * Affiche les messages d'une discussion.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/09
  * @param integer $id Id de la discussion
  * @param integer $page (option) Page courante. Si null, vaut 1.
  * @param string $go (option) Si vaut "new", redirige sur le premier message non lu de la discussion
  * @param integer $message (option) Si positionne, redirige sur le message (a la bonne page)
  */
 public function getTopic()
 {
     $id = _request("id") ? _request("id") : NULL;
     $go = _request("go") ? _request("go") : NULL;
     $message = _request("message") ? _request("message") : NULL;
     $page = _request("page") ? _request("page") : 1;
     $errors = array();
     $countClick = true;
     // Todo voir si en session pour pas compter la lecture de chaque page ?
     $dao_topics = CopixDAOFactory::create("forum_topics");
     $dao_messages = CopixDAOFactory::create("forum_messages_topics");
     $forumService = CopixClassesFactory::create("forum|forumService");
     if ($go == "new") {
         $daoTracking = CopixDAOFactory::create("forum|forum_tracking2");
         $unread = $daoTracking->getFirstUnreadMessage($id, _currentUser()->getId());
         //print_r($unread);
         if ($unread[0]->id) {
             // Il est deja passe dans le topic
             $urlReturn = CopixUrl::get('forum||getTopic', array("message" => $unread[0]->id)) . "#" . $unread[0]->id;
         } else {
             // Jamais passe, on le renvoie au debut du topic
             $urlReturn = CopixUrl::get('forum||getTopic', array("id" => $id));
         }
         return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
     }
     if ($message) {
         $rMessage = $dao_messages->get($message);
         if ($rMessage) {
             $id = $rMessage->topic_id;
             // On cherche ensuite a quelle page il faut aller pour trouver ce message
             $before = $dao_messages->getListMessagesInTopicBefore($id, $message, $rMessage->date);
             $page = ceil((count($before) + 1) / CopixConfig::get('forum|list_nbmessages'));
             //print_r($before);
         }
     }
     $rTopic = $dao_topics->get($id);
     if (!$rTopic) {
         $errors[] = CopixI18N::get('forum|forum.error.noTopic');
     } else {
         $mondroit = Kernel::getLevel("MOD_FORUM", $rTopic->forum_id);
         if (!$forumService->canMakeInForum("READ", $mondroit)) {
             $errors[] = CopixI18N::get('kernel|kernel.error.noRights');
         }
     }
     if ($errors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('forum||')));
     } else {
         if ($countClick) {
             $rTopic->nb_lectures = $rTopic->nb_lectures + 1;
             $dao_topics->update($rTopic);
         }
         // On enregistre sa lecture (tracking)
         $user = _currentUser()->getId();
         $forumService->userReadTopic($id, $user);
         // Les messages de ce forum
         $offset = ($page - 1) * CopixConfig::get('forum|list_nbmessages');
         $all = $dao_messages->getListMessagesInTopicAll($id);
         $nbPages = ceil(count($all) / CopixConfig::get('forum|list_nbmessages'));
         $list = $dao_messages->getListMessagesInTopic($id, $offset, CopixConfig::get('forum|list_nbmessages'));
         // Pour chaque message on cherche les infos de son auteur
         foreach ($list as $k => $null) {
             $userInfo = Kernel::getUserInfo("ID", $list[$k]->auteur);
             $list[$k]->auteur_infos = $userInfo["prenom"] . " " . $userInfo["nom"];
             // Avatar de l'expediteur
             $avatar = Prefs::get('prefs', 'avatar', $list[$k]->auteur);
             $list[$k]->avatar = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         }
         $tpl = new CopixTpl();
         $tpl->assign('TITLE_PAGE', $rTopic->titre);
         $menu = array();
         if ($forumService->canMakeInForum('MODIFY_TOPIC', $mondroit)) {
             $menu[] = array('txt' => CopixI18N::get('forum|forum.btn.modify'), 'url' => CopixUrl::get('forum||getTopicForm', array("id" => $id)), 'type' => 'update');
         }
         if ($forumService->canMakeInForum('DELETE_TOPIC', $mondroit)) {
             $menu[] = array('txt' => CopixI18N::get('forum|forum.btn.delete'), 'url' => CopixUrl::get('forum||getDeleteTopic', array("id" => $id)), 'type' => 'delete');
         }
         $tpl->assign('MENU', $menu);
         $tplForum = new CopixTpl();
         $tplForum->assign('topic', $rTopic);
         $tplForum->assign('list', $list);
         $tplForum->assign('reglettepages', CopixZone::process('kernel|reglettepages', array('page' => $page, 'nbPages' => $nbPages, 'separator' => '&', 'url' => CopixUrl::get('forum||getTopic', array("id" => $id)))));
         $tplForum->assign('petitpoucet', CopixZone::process('forum|petitpoucet', array('topic' => $rTopic)));
         $tplForum->assign('canModifyMessage', $forumService->canMakeInForum('MODIFY_MESSAGE', $mondroit) ? 1 : 0);
         $tplForum->assign('canDeleteMessage', $forumService->canMakeInForum('DELETE_MESSAGE', $mondroit) ? 1 : 0);
         $tplForum->assign('canAddMessage', $forumService->canMakeInForum('ADD_MESSAGE', $mondroit) ? 1 : 0);
         $result = $tplForum->fetch('gettopic.tpl');
         $tpl->assign('MAIN', $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
예제 #27
0
// | 51 Franklin Street, Suite 330                                          |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('self_assign.tpl.html');
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$usr_id = Auth::getUserID();
$prj_id = Auth::getCurrentProject();
$issue_id = $_REQUEST['iss_id'];
$tpl->assign('issue_id', $issue_id);
// check if issue is assigned to someone else and if so, confirm change.
$assigned_user_ids = Issue::getAssignedUserIDs($issue_id);
if (count($assigned_user_ids) > 0 && empty($_REQUEST['target'])) {
    $tpl->assign(array('prompt_override' => 1, 'assigned_users' => Issue::getAssignedUsers($issue_id)));
} else {
    $issue_details = Issue::getDetails($issue_id);
    // force assignment change
    if (@$_REQUEST['target'] == 'replace') {
        // remove current user(s) first
        Issue::deleteUserAssociations($issue_id, $usr_id);
    }
    $res = Issue::addUserAssociation($usr_id, $issue_id, $usr_id);
    $tpl->assign('self_assign_result', $res);
    Notification::subscribeUser($usr_id, $issue_id, $usr_id, Notification::getDefaultActions($issue_id, User::getEmail($usr_id), 'self_assign'));
    Workflow::handleAssignmentChange($prj_id, $issue_id, $usr_id, $issue_details, Issue::getAssignedUserIDs($issue_id), false);
}
$tpl->assign('current_user_prefs', Prefs::get($usr_id));
$tpl->displayTemplate();
예제 #28
0
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
// | GNU General Public License for more details.                         |
// |                                                                      |
// | You should have received a copy of the GNU General Public License    |
// | along with this program; if not, write to:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                          |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: Bryan Alsdorf <*****@*****.**>                          |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('select_partners.tpl.html');
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$issue_id = @$_POST['issue_id'] ? $_POST['issue_id'] : $_GET['iss_id'];
if (!Access::canViewDrafts($issue_id, Auth::getUserID()) || Auth::getCurrentRole() <= User::getRoleID('Standard User')) {
    $tpl = new Template_Helper();
    $tpl->setTemplate('permission_denied.tpl.html');
    $tpl->displayTemplate();
    exit;
}
$prj_id = Issue::getProjectID($issue_id);
if (@$_POST['cat'] == 'update') {
    $res = Partner::selectPartnersForIssue($_POST['issue_id'], @$_POST['partners']);
    $tpl->assign('update_result', $res);
}
$tpl->assign(array('issue_id' => $issue_id, 'enabled_partners' => Partner::getPartnersByProject($prj_id), 'partners' => Partner::getPartnersByIssue($issue_id), 'current_user_prefs' => Prefs::get(Auth::getUserID())));
$tpl->displayTemplate();
예제 #29
0
 /**
  * Returns the data used by the weekly report.
  *
  * @param string $usr_id The ID of the user this report is for.
  * @param int $prj_id The project id
  * @param string|DateTime $start The start date of this report.
  * @param string|DateTime $end The end date of this report.
  * @param array $options extra options for report:
  * - $separate_closed If closed issues should be separated from other issues.
  * - $ignore_statuses If issue status changes should be ignored in report.
  * - $separate_not_assigned_to_user Separate Issues Not Assigned to User
  * - $show_per_issue Add time spent on issue to issues
  * - $separate_no_time Separate No time spent issues
  * @return array An array of data containing all the elements of the weekly report.
  */
 public static function getWeeklyReport($usr_id, $prj_id, $start, $end, $options = array())
 {
     // figure out timezone
     $user_prefs = Prefs::get($usr_id);
     $tz = $user_prefs['timezone'];
     // if start or end is string, convert assume min and max date are specified
     if (!$start instanceof DateTime) {
         $start = Date_Helper::getDateTime($start, $tz)->setTime(0, 0, 0);
     }
     if (!$end instanceof DateTime) {
         $end = Date_Helper::getDateTime($end, $tz)->setTime(23, 59, 59);
     }
     $start_ts = Date_Helper::getSqlDateTime($start);
     $end_ts = Date_Helper::getSqlDateTime($end);
     $time_tracking = Time_Tracking::getSummaryByUser($usr_id, $prj_id, $start_ts, $end_ts);
     // replace spaces in index with _ and calculate total time
     $total_time = 0;
     foreach ($time_tracking as $category => $data) {
         unset($time_tracking[$category]);
         $time_tracking[str_replace(' ', '_', $category)] = $data;
         $total_time += $data['total_time'];
     }
     // get count of issues assigned in week of report.
     $stmt = 'SELECT
                 COUNT(*)
              FROM
                 {{%issue}},
                 {{%issue_user}},
                 {{%status}}
              WHERE
                 iss_id = isu_iss_id AND
                 iss_sta_id = sta_id AND
                 isu_usr_id = ? AND
                 iss_prj_id = ? AND
                 isu_assigned_date BETWEEN ? AND ?';
     $params = array($usr_id, Auth::getCurrentProject(), $start_ts, $end_ts);
     try {
         $newly_assigned = DB_Helper::getInstance()->getOne($stmt, $params);
     } catch (DbException $e) {
         $newly_assigned = null;
     }
     $email_count = array('associated' => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, true), 'other' => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, false));
     $htt_exclude = array();
     if (!empty($options['ignore_statuses'])) {
         $htt_exclude[] = 'status_changed';
         $htt_exclude[] = 'status_auto_changed';
         $htt_exclude[] = 'remote_status_change';
     }
     $issue_list = History::getTouchedIssuesByUser($usr_id, $prj_id, $start_ts, $end_ts, $htt_exclude);
     $issues = array('no_time' => array(), 'not_mine' => array(), 'closed' => array(), 'other' => array());
     // organize issues into categories
     if ($issue_list) {
         if (!empty($options['show_per_issue']) || !empty($options['separate_no_time'])) {
             Time_Tracking::fillTimeSpentByIssueAndTime($issue_list, $usr_id, $start_ts, $end_ts);
         }
         foreach ($issue_list as $row) {
             if (!empty($row['iss_customer_id']) && CRM::hasCustomerIntegration($row['iss_prj_id'])) {
                 $row['customer_name'] = CRM::getCustomerName($row['iss_prj_id'], $row['iss_customer_id']);
             } else {
                 $row['customer_name'] = null;
             }
             if (!empty($options['separate_closed']) && $row['sta_is_closed'] == 1) {
                 $issues['closed'][] = $row;
             } elseif (!empty($options['separate_not_assigned_to_user']) && !Issue::isAssignedToUser($row['iss_id'], $usr_id)) {
                 $issues['not_mine'][] = $row;
             } elseif (!empty($options['separate_no_time']) && empty($row['it_spent'])) {
                 $issues['no_time'][] = $row;
             } else {
                 $issues['other'][] = $row;
             }
         }
         $sort_function = function ($a, $b) {
             return strcasecmp($a['customer_name'], $b['customer_name']);
         };
         usort($issues['closed'], $sort_function);
         usort($issues['other'], $sort_function);
     }
     return array('start' => $start_ts, 'end' => $end_ts, 'user' => User::getDetails($usr_id), 'group_name' => Group::getName(User::getGroupID($usr_id)), 'issues' => $issues, 'status_counts' => History::getTouchedIssueCountByStatus($usr_id, $prj_id, $start_ts, $end_ts), 'new_assigned_count' => $newly_assigned, 'time_tracking' => $time_tracking, 'email_count' => $email_count, 'phone_count' => Phone_Support::getCountByUser($usr_id, $start_ts, $end_ts), 'note_count' => Note::getCountByUser($usr_id, $start_ts, $end_ts), 'total_time' => Misc::getFormattedTime($total_time, false));
 }
예제 #30
0
 /**
  * Method used to get the timezone preferred by the user.
  *
  * @access  public
  * @param   integer $usr_id The user ID
  * @return  string The timezone preferred by the user
  */
 function getPreferredTimezone($usr_id = FALSE)
 {
     if ($usr_id === FALSE) {
         $usr_id = Auth::getUserID();
     }
     if (empty($usr_id)) {
         return Date_API::getDefaultTimezone();
     }
     $prefs = Prefs::get($usr_id);
     if (empty($prefs["timezone"])) {
         return Date_API::getDefaultTimezone();
     } else {
         return $prefs["timezone"];
     }
 }