First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,79 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* Main page for activity dashlet
*
*/
class CRM_Dashlet_Page_Activity extends CRM_Core_Page {
/**
* List activities as dashlet.
*
* @return void
*/
public function run() {
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
$this->assign('contactID', $contactID);
$this->assign('contactId', $contactID);
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'dashlet');
$this->assign('context', $context);
// a user can always view their own activity
// if they have access CiviCRM permission
$permission = CRM_Core_Permission::VIEW;
// make the permission edit if the user has edit permission on the contact
if (CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) {
$permission = CRM_Core_Permission::EDIT;
}
$admin = CRM_Core_Permission::check('view all activities') || CRM_Core_Permission::check('administer CiviCRM');
$this->assign('admin', $admin);
// also create the form element for the activity filter box
$controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_ActivityFilter',
ts('Activity Filter'), NULL
);
$controller->setEmbedded(TRUE);
$controller->run();
return parent::run();
}
}

View file

@ -0,0 +1,66 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* Main page for Cases dashlet
*
*/
class CRM_Dashlet_Page_AllCases extends CRM_Core_Page {
/**
* List activities as dashlet.
*
* @return void
*/
public function run() {
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'dashlet');
$this->assign('context', $context);
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$upcoming = CRM_Case_BAO_Case::getCases(TRUE, $userID, 'upcoming', $context);
if (!empty($upcoming)) {
$this->assign('AllCases', $upcoming);
}
return parent::run();
}
}

View file

@ -0,0 +1,164 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* Main page for blog dashlet
*/
class CRM_Dashlet_Page_Blog extends CRM_Core_Page {
const CHECK_TIMEOUT = 5;
const CACHE_DAYS = 1;
const NEWS_URL = 'https://civicrm.org/news-feed.rss';
/**
* Gets url for blog feed.
*
* @return string
*/
public function getNewsUrl() {
// Note: We use "*default*" as the default (rather than self::NEWS_URL) so that future
// developers can change NEWS_URL without needing to update {civicrm_setting}.
$url = Civi::settings()->get('blogUrl');
if ($url === '*default*') {
$url = self::NEWS_URL;
}
return CRM_Utils_System::evalUrl($url);
}
/**
* Output data to template.
*/
public function run() {
$this->assign('feeds', $this->getData());
return parent::run();
}
/**
* Load feeds from cache.
*
* Refresh cache if expired.
*
* @return array
*/
protected function getData() {
// Fetch data from cache
$cache = CRM_Core_DAO::executeQuery("SELECT data, created_date FROM civicrm_cache
WHERE group_name = 'dashboard' AND path = 'newsfeed'");
if ($cache->fetch()) {
$expire = time() - (60 * 60 * 24 * self::CACHE_DAYS);
// Refresh data after CACHE_DAYS
if (strtotime($cache->created_date) < $expire) {
$new_data = $this->getFeeds();
// If fetching the new rss feed was successful, return it
// Otherwise use the old cached data - it's better than nothing
if ($new_data) {
return $new_data;
}
}
return unserialize($cache->data);
}
return $this->getFeeds();
}
/**
* Fetch all feeds & cache results.
*
* @return array
*/
protected function getFeeds() {
$newsFeed = $this->getFeed($this->getNewsUrl());
// If unable to fetch the feed, return empty results.
if (!$newsFeed) {
return array();
}
$feeds = $this->formatItems($newsFeed);
CRM_Core_BAO_Cache::setItem($feeds, 'dashboard', 'newsfeed');
return $feeds;
}
/**
* Parse a single rss feed.
*
* @param $url
*
* @return array|NULL
* array of blog items; or NULL if not available
*/
protected function getFeed($url) {
$httpClient = new CRM_Utils_HttpClient(self::CHECK_TIMEOUT);
list ($status, $rawFeed) = $httpClient->get($url);
if ($status !== CRM_Utils_HttpClient::STATUS_OK) {
return NULL;
}
return @simplexml_load_string($rawFeed);
}
/**
* @param string $feed
* @return array
*/
protected function formatItems($feed) {
$result = array();
if ($feed && !empty($feed->channel)) {
foreach ($feed->channel as $channel) {
$content = array(
'title' => (string) $channel->title,
'description' => (string) $channel->description,
'name' => strtolower(CRM_Utils_String::munge($channel->title, '-')),
'items' => array(),
);
foreach ($channel->item as $item) {
$item = (array) $item;
$item['title'] = strip_tags($item['title']);
// Clean up description - remove tags & styles that would break dashboard layout
$description = preg_replace('#<h[1-3][^>]*>(.+?)</h[1-3][^>]*>#s', '<h4>$1</h4>', $item['description']);
$description = strip_tags($description, "<a><p><h4><h5><h6><b><i><em><strong><ol><ul><li><dd><dt><code><pre><br><hr>");
$description = preg_replace('/(<[^>]+) style=["\'].*?["\']/i', '$1', $description);
// Add paragraph markup if it's missing.
if (strpos($description, '<p') === FALSE) {
$description = '<p>' . $description . '</p>';
}
$item['description'] = $description;
$content['items'][] = $item;
}
if ($content['items']) {
$result[] = $content;
}
}
}
return $result;
}
}

View file

@ -0,0 +1,65 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* Main page for Case Dashboard dashlet
*
*/
class CRM_Dashlet_Page_CaseDashboard extends CRM_Core_Page {
/**
* Case dashboard as dashlet.
*
* @return void
*/
public function run() {
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
$session = &CRM_Core_Session::singleton();
$userID = $session->get('userID');
$summary = CRM_Case_BAO_Case::getCasesSummary(TRUE, $userID);
if (!empty($summary)) {
$this->assign('casesSummary', $summary);
}
return parent::run();
}
}

View file

@ -0,0 +1,154 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* Main page for getting started dashlet
*/
class CRM_Dashlet_Page_GettingStarted extends CRM_Core_Page {
const CHECK_TIMEOUT = 5;
const CACHE_DAYS = 5;
const GETTING_STARTED_URL = 'https://alert.civicrm.org/welcome?prot=1&ver={ver}&uf={uf}&sid={sid}&lang={lang}&co={co}';
/**
* Define tokens available for getting started
*/
static $_tokens = array(
'crmurl' => array(
'configbackend' => 'civicrm/admin/configtask',
),
);
/**
* Get the final, usable URL string (after interpolating any variables)
*
* @return FALSE|string
*/
public function gettingStartedUrl() {
// Note: We use "*default*" as the default (rather than self::GETTING_STARTED_URL) so that future
// developers can change GETTING_STARTED_URL without needing to update {civicrm_setting}.
$url = Civi::settings()->get('gettingStartedUrl');
if ($url === '*default*') {
$url = self::GETTING_STARTED_URL;
}
return CRM_Utils_System::evalUrl($url);
}
/**
* List gettingStarted page as dashlet.
*/
public function run() {
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'dashlet');
// Assign smarty variables.
$this->assign('context', $context);
$this->assign('gettingStarted', $this->_gettingStarted());
// Use smarty to generate page.
return parent::run();
}
/**
* Load gettingStarted page from cache.
* Refresh cache if expired
*
* @return array
*/
private function _gettingStarted() {
// Fetch data from cache
$cache = CRM_Core_DAO::executeQuery("SELECT data, created_date FROM civicrm_cache
WHERE group_name = 'dashboard' AND path = 'gettingStarted'");
if ($cache->fetch()) {
$expire = time() - (60 * 60 * 24 * self::CACHE_DAYS);
// Refresh data after CACHE_DAYS
if (strtotime($cache->created_date) < $expire) {
$new_data = $this->_getHtml($this->gettingStartedUrl());
// If fetching the new html was successful, return it
// Otherwise use the old cached data - it's better than nothing
if ($new_data) {
return $new_data;
}
}
return unserialize($cache->data);
}
return $this->_getHtml($this->gettingStartedUrl());
}
/**
* Get html and cache results.
*
* @param $url
*
* @return array|NULL
* array of gettingStarted items; or NULL if not available
*/
public function _getHtml($url) {
$httpClient = new CRM_Utils_HttpClient(self::CHECK_TIMEOUT);
list ($status, $html) = $httpClient->get($url);
if ($status !== CRM_Utils_HttpClient::STATUS_OK) {
return NULL;
}
$tokensList = CRM_Utils_Token::getTokens($html);
$this->replaceLinkToken($tokensList, $html);
if ($html) {
CRM_Core_BAO_Cache::setItem($html, 'dashboard', 'gettingStarted');
}
return $html;
}
/**
* @param array $tokensList
* @param string $str
*
*/
public function replaceLinkToken($tokensList, &$str) {
foreach ($tokensList as $categories => $tokens) {
foreach ($tokens as $token) {
$value = '';
if (!empty(self::$_tokens[$categories][$token])) {
$value = self::$_tokens[$categories][$token];
if ($categories == 'crmurl') {
$value = CRM_Utils_System::url($value, "reset=1");
}
}
CRM_Utils_Token::token_replace($categories, $token, $value, $str);
}
}
}
}

View file

@ -0,0 +1,66 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* Main page for Cases dashlet
*
*/
class CRM_Dashlet_Page_MyCases extends CRM_Core_Page {
/**
* List activities as dashlet.
*
* @return void
*/
public function run() {
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'dashlet');
$this->assign('context', $context);
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$upcoming = CRM_Case_BAO_Case::getCases(FALSE, $userID, 'upcoming', $context);
if (!empty($upcoming)) {
$this->assign('upcomingCases', $upcoming);
}
return parent::run();
}
}