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

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,100 @@
<?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
*/
/**
* Main page for viewing all Saved searches.
*/
class CRM_Contact_Page_CustomSearch extends CRM_Core_Page {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* @return array
*/
public static function &info() {
$sql = "
SELECT v.value, v.label, v.description
FROM civicrm_option_group g,
civicrm_option_value v
WHERE v.option_group_id = g.id
AND g.name = 'custom_search'
AND v.is_active = 1
ORDER By v.weight
";
$dao = CRM_Core_DAO::executeQuery($sql,
CRM_Core_DAO::$_nullArray
);
$rows = array();
while ($dao->fetch()) {
if (trim($dao->description)) {
$rows[$dao->value] = $dao->description;
}
else {
$rows[$dao->value] = $dao->label;
}
}
return $rows;
}
/**
* Browse all custom searches.
*
* @return mixed
* content of the parents run method
*/
public function browse() {
$rows = self::info();
$this->assign('rows', $rows);
return parent::run();
}
/**
* Run this page (figure out the action needed and perform it).
*/
public function run() {
$action = CRM_Utils_Request::retrieve('action',
'String',
$this, FALSE, 'browse'
);
$this->assign('action', $action);
return $this->browse();
}
}

View file

@ -0,0 +1,72 @@
<?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
*/
/**
* CiviCRM Dashboard.
*/
class CRM_Contact_Page_DashBoard extends CRM_Core_Page {
/**
* Run dashboard.
*/
public function run() {
// Add dashboard js and css
$resources = CRM_Core_Resources::singleton();
$resources->addScriptFile('civicrm', 'js/jquery/jquery.dashboard.js', 0, 'html-header', FALSE);
$resources->addStyleFile('civicrm', 'css/dashboard.css');
$this->assign('contactDashlets', CRM_Core_BAO_Dashboard::getContactDashletsForJS());
CRM_Utils_System::setTitle(ts('CiviCRM Home'));
$contactID = CRM_Core_Session::getLoggedInContactID();
// call hook to get html from other modules
// ignored but needed to prevent warnings
$contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW;
$html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement);
if (is_array($html)) {
$this->assign_by_ref('hookContent', $html);
$this->assign('hookContentPlacement', $contentPlacement);
}
$communityMessages = CRM_Core_CommunityMessages::create();
if ($communityMessages->isEnabled()) {
$message = $communityMessages->pick();
if ($message) {
$this->assign('communityMessages', $communityMessages->evalMarkup($message['markup']));
}
}
return parent::run();
}
}

View file

@ -0,0 +1,77 @@
<?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
*/
/**
* CiviCRM Dashlet.
*/
class CRM_Contact_Page_Dashlet extends CRM_Core_Page {
/**
* Run dashboard.
*/
public function run() {
CRM_Utils_System::setTitle(ts('Dashlets'));
$this->assign('admin', CRM_Core_Permission::check('administer CiviCRM'));
// get all dashlets
$allDashlets = CRM_Core_BAO_Dashboard::getDashlets(FALSE);
// get dashlets for logged in contact
$currentDashlets = CRM_Core_BAO_Dashboard::getContactDashlets();
$contactDashlets = $availableDashlets = array();
foreach ($currentDashlets as $item) {
$key = "{$item['dashboard_id']}-0";
$contactDashlets[$item['column_no']][$key] = array(
'label' => $item['label'],
'is_reserved' => $allDashlets[$item['dashboard_id']]['is_reserved'],
);
unset($allDashlets[$item['dashboard_id']]);
}
foreach ($allDashlets as $dashletID => $values) {
$key = "{$dashletID}-0";
$availableDashlets[$key] = array(
'label' => $values['label'],
'is_reserved' => $values['is_reserved'],
);
}
$this->assign('contactDashlets', $contactDashlets);
$this->assign('availableDashlets', $availableDashlets);
return parent::run();
}
}

View file

@ -0,0 +1,87 @@
<?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
*/
/**
* Main page for viewing contact.
*/
class CRM_Contact_Page_DedupeException extends CRM_Core_Page {
/**
* Heart of the viewing process.
*
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
//fetch the dedupe exception contacts.
$dedupeExceptions = array();
$exception = new CRM_Dedupe_DAO_Exception();
$exception->find();
$contactIds = array();
while ($exception->fetch()) {
$key = "{$exception->contact_id1}_{$exception->contact_id2}";
$contactIds[$exception->contact_id1] = $exception->contact_id1;
$contactIds[$exception->contact_id2] = $exception->contact_id2;
$dedupeExceptions[$key] = array(
'main' => array('id' => $exception->contact_id1),
'other' => array('id' => $exception->contact_id2),
);
}
//get the dupe contacts display names.
if (!empty($dedupeExceptions)) {
$sql = 'select id, display_name from civicrm_contact where id IN ( ' . implode(', ', $contactIds) . ' )';
$contact = CRM_Core_DAO::executeQuery($sql);
$displayNames = array();
while ($contact->fetch()) {
$displayNames[$contact->id] = $contact->display_name;
}
foreach ($dedupeExceptions as $key => & $values) {
$values['main']['name'] = CRM_Utils_Array::value($values['main']['id'], $displayNames);
$values['other']['name'] = CRM_Utils_Array::value($values['other']['id'], $displayNames);
}
}
$this->assign('dedupeExceptions', $dedupeExceptions);
}
/**
* the main function that is called when the page loads,
* it decides the which action has to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
return parent::run();
}
}

View file

@ -0,0 +1,249 @@
<?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
*/
class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
protected $_cid = NULL;
protected $_rgid;
protected $_mainContacts;
protected $_gid;
protected $action;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Dedupe_BAO_RuleGroup';
}
/**
* Get action Links.
*/
public function &links() {
}
/**
* Browse all rule groups.
*/
public function run() {
$gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0);
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$limit = CRM_Utils_Request::retrieve('limit', 'Integer', $this);
$rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this);
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0);
// Using a placeholder for criteria as it is intended to be able to pass this later.
$criteria = array();
$isConflictMode = ($context == 'conflicts');
if ($cid) {
$this->_cid = $cid;
}
if ($gid) {
$this->_gid = $gid;
}
$this->_rgid = $rgid;
$urlQry = array(
'reset' => 1,
'rgid' => $rgid,
'gid' => $gid,
'limit' => $limit,
);
$this->assign('urlQuery', CRM_Utils_System::makeQueryString($urlQry));
if ($context == 'search') {
$context = 'search';
$this->assign('backURL', CRM_Core_Session::singleton()->readUserContext());
}
if ($action & CRM_Core_Action::RENEW) {
// empty cache
if ($rgid) {
CRM_Core_BAO_PrevNextCache::deleteItem(NULL, CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid, $criteria));
}
$urlQry['action'] = 'update';
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry));
}
elseif ($action & CRM_Core_Action::MAP) {
// do a batch merge if requested
$result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, 'safe', 75, 2, $criteria);
$skippedCount = CRM_Utils_Request::retrieve('skipped', 'Positive', $this, FALSE, 0);
$skippedCount = $skippedCount + count($result['skipped']);
$mergedCount = CRM_Utils_Request::retrieve('merged', 'Positive', $this, FALSE, 0);
$mergedCount = $mergedCount + count($result['merged']);
if (empty($result['merged']) && empty($result['skipped'])) {
$message = '';
if ($mergedCount >= 1) {
$message = ts("%1 pairs of duplicates were merged", array(1 => $mergedCount));
}
if ($skippedCount >= 1) {
$message = $message ? "{$message} and " : '';
$message .= ts("%1 pairs of duplicates were skipped due to conflict",
array(1 => $skippedCount)
);
}
$message .= ts(" during the batch merge process with safe mode.");
CRM_Core_Session::setStatus($message, ts('Merge Complete'), 'success');
$urlQry['action'] = 'update';
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry));
}
else {
$urlQry['action'] = 'map';
$urlQry['skipped'] = $skippedCount;
$urlQry['merged'] = $mergedCount;
CRM_Utils_System::jsRedirect(
CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry),
ts('Batch Merge Task in progress'),
ts('The batch merge task is still in progress. This page will be refreshed automatically.')
);
}
}
if ($action & CRM_Core_Action::UPDATE ||
$action & CRM_Core_Action::BROWSE
) {
$this->action = CRM_Core_Action::UPDATE;
$urlQry['snippet'] = 4;
if ($isConflictMode) {
$urlQry['selected'] = 1;
}
$this->assign('sourceUrl', CRM_Utils_System::url('civicrm/ajax/dedupefind', $urlQry, FALSE, NULL, FALSE));
//reload from cache table
$cacheKeyString = CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid, $criteria);
$stats = CRM_Dedupe_Merger::getMergeStatsMsg($cacheKeyString);
if ($stats) {
CRM_Core_Session::setStatus($stats);
// reset so we not displaying same message again
CRM_Dedupe_Merger::resetMergeStats($cacheKeyString);
}
$this->_mainContacts = CRM_Dedupe_Merger::getDuplicatePairs($rgid, $gid, !$isConflictMode, 0, $isConflictMode, '', $isConflictMode, $criteria, TRUE);
if (empty($this->_mainContacts)) {
if ($isConflictMode) {
// if the current screen was intended to list only selected contacts, move back to full dupe list
$urlQry['action'] = 'update';
unset($urlQry['snippet']);
CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), $urlQry));
}
$ruleGroupName = civicrm_api3('RuleGroup', 'getvalue', array('id' => $rgid, 'return' => 'name'));
CRM_Core_Session::singleton()->setStatus(ts('No possible duplicates were found using %1 rule.', array(1 => $ruleGroupName)), ts('None Found'), 'info');
$url = CRM_Utils_System::url('civicrm/contact/deduperules', 'reset=1');
if ($context == 'search') {
$url = CRM_Core_Session::singleton()->readUserContext();
}
CRM_Utils_System::redirect($url);
}
else {
$urlQry['action'] = 'update';
if ($this->_cid) {
$urlQry['cid'] = $this->_cid;
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/contact/deduperules',
$urlQry
));
}
else {
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/contact/dedupefind',
$urlQry
));
}
}
$this->assign('action', $this->action);
$this->browse();
}
else {
$this->action = CRM_Core_Action::UPDATE;
$this->edit($this->action);
$this->assign('action', $this->action);
}
$this->assign('context', $context);
return parent::run();
}
/**
* Browse all rule groups.
*/
public function browse() {
$this->assign('main_contacts', $this->_mainContacts);
if ($this->_cid) {
$this->assign('cid', $this->_cid);
}
if (isset($this->_gid) || $this->_gid) {
$this->assign('gid', $this->_gid);
}
$this->assign('rgid', $this->_rgid);
}
/**
* Get name of edit form.
*
* @return string
* classname of edit form
*/
public function editForm() {
return 'CRM_Contact_Form_DedupeFind';
}
/**
* Get edit form name.
*
* @return string
* name of this page
*/
public function editName() {
return 'DedupeFind';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context
*/
public function userContext($mode = NULL) {
return 'civicrm/contact/dedupefind';
}
}

View file

@ -0,0 +1,139 @@
<?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
*/
class CRM_Contact_Page_DedupeMerge extends CRM_Core_Page {
const BATCHLIMIT = 2;
/**
* Browse batch merges.
*/
public function run() {
$runner = self::getRunner();
if ($runner) {
// Run Everything in the Queue via the Web.
$runner->runAllViaWeb();
}
else {
CRM_Core_Session::setStatus(ts('Nothing to merge.'));
}
// parent run
return parent::run();
}
/**
* Build a queue of tasks by dividing dupe pairs in batches.
*/
public static function getRunner() {
$rgid = CRM_Utils_Request::retrieve('rgid', 'Positive');
$gid = CRM_Utils_Request::retrieve('gid', 'Positive');
$limit = CRM_Utils_Request::retrieve('limit', 'Positive');
$action = CRM_Utils_Request::retrieve('action', 'String');
$mode = CRM_Utils_Request::retrieve('mode', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'safe');
$cacheKeyString = CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid);
$urlQry = "reset=1&action=update&rgid={$rgid}&gid={$gid}&limit={$limit}";
if ($mode == 'aggressive' && !CRM_Core_Permission::check('force merge duplicate contacts')) {
CRM_Core_Session::setStatus(ts('You do not have permission to force merge duplicate contact records'), ts('Permission Denied'), 'error');
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry));
}
// Setup the Queue
$queue = CRM_Queue_Service::singleton()->create(array(
'name' => $cacheKeyString,
'type' => 'Sql',
'reset' => TRUE,
));
$where = NULL;
if ($action == CRM_Core_Action::MAP) {
$where = "pn.is_selected = 1";
$isSelected = 1;
}
else {
// else merge all (2)
$isSelected = 2;
}
$total = CRM_Core_BAO_PrevNextCache::getCount($cacheKeyString, NULL, $where);
if ($total <= 0) {
// Nothing to do.
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry));
}
// reset merge stats, so we compute new stats
CRM_Dedupe_Merger::resetMergeStats($cacheKeyString);
for ($i = 1; $i <= ceil($total / self::BATCHLIMIT); $i++) {
$task = new CRM_Queue_Task(
array('CRM_Contact_Page_DedupeMerge', 'callBatchMerge'),
array($rgid, $gid, $mode, self::BATCHLIMIT, $isSelected),
"Processed " . $i * self::BATCHLIMIT . " pair of duplicates out of " . $total
);
// Add the Task to the Queue
$queue->createItem($task);
}
// Setup the Runner
$urlQry .= "&context=conflicts";
$runner = new CRM_Queue_Runner(array(
'title' => ts('Merging Duplicates..'),
'queue' => $queue,
'errorMode' => CRM_Queue_Runner::ERROR_ABORT,
'onEndUrl' => CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry, TRUE, NULL, FALSE),
));
return $runner;
}
/**
* Carry out batch merges.
*
* @param \CRM_Queue_TaskContext $ctx
* @param int $rgid
* @param int $gid
* @param string $mode
* 'safe' mode or 'force' mode.
* @param int $batchLimit
* @param int $isSelected
*
* @return int
*/
public static function callBatchMerge(CRM_Queue_TaskContext $ctx, $rgid, $gid, $mode = 'safe', $batchLimit, $isSelected) {
CRM_Dedupe_Merger::batchMerge($rgid, $gid, $mode, $batchLimit, $isSelected);
return CRM_Queue_Task::TASK_SUCCESS;
}
}

View file

@ -0,0 +1,220 @@
<?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
*/
class CRM_Contact_Page_DedupeRules extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Dedupe_BAO_RuleGroup';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
$deleteExtra = ts('Are you sure you want to delete this Rule?');
// helper variable for nicer formatting
$links = array();
if (CRM_Core_Permission::check('merge duplicate contacts')) {
$links[CRM_Core_Action::VIEW] = array(
'name' => ts('Use Rule'),
'url' => 'civicrm/contact/dedupefind',
'qs' => 'reset=1&rgid=%%id%%&action=preview',
'title' => ts('Use DedupeRule'),
);
}
if (CRM_Core_Permission::check('administer dedupe rules')) {
$links[CRM_Core_Action::UPDATE] = array(
'name' => ts('Edit Rule'),
'url' => 'civicrm/contact/deduperules',
'qs' => 'action=update&id=%%id%%',
'title' => ts('Edit DedupeRule'),
);
$links[CRM_Core_Action::DELETE] = array(
'name' => ts('Delete'),
'url' => 'civicrm/contact/deduperules',
'qs' => 'action=delete&id=%%id%%',
'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"',
'title' => ts('Delete DedupeRule'),
);
}
self::$_links = $links;
}
return self::$_links;
}
/**
* Run the page.
*
* This method is called after the page is created. It checks for the type
* of action and executes that action. Finally it calls the parent's run
* method.
*/
public function run() {
$id = $this->getIdAndAction();
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE);
if ($context == 'nonDupe') {
CRM_Core_Session::setStatus(ts('Selected contacts have been marked as not duplicates'), ts('Changes Saved'), 'success');
}
// assign permissions vars to template
$this->assign('hasperm_administer_dedupe_rules', CRM_Core_Permission::check('administer dedupe rules'));
$this->assign('hasperm_merge_duplicate_contacts', CRM_Core_Permission::check('merge duplicate contacts'));
// which action to take?
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
$this->edit($this->_action, $id);
}
if ($this->_action & CRM_Core_Action::DELETE) {
$this->delete($id);
}
// browse the rules
$this->browse();
// This replaces parent run, but do parent's parent run
return CRM_Core_Page::run();
}
/**
* Browse all rule groups.
*/
public function browse() {
// get all rule groups
$ruleGroups = array();
$dao = new CRM_Dedupe_DAO_RuleGroup();
$dao->orderBy('contact_type ASC, used ASC, title ASC');
$dao->find();
$dedupeRuleTypes = CRM_Core_SelectValues::getDedupeRuleTypes();
while ($dao->fetch()) {
$ruleGroups[$dao->contact_type][$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $ruleGroups[$dao->contact_type][$dao->id]);
// form all action links
$action = array_sum(array_keys($this->links()));
$links = self::links();
/* if ($dao->is_default) {
unset($links[CRM_Core_Action::MAP]);
unset($links[CRM_Core_Action::DELETE]);
}*/
if ($dao->is_reserved) {
unset($links[CRM_Core_Action::DELETE]);
}
$ruleGroups[$dao->contact_type][$dao->id]['action'] = CRM_Core_Action::formLink(
$links,
$action,
array('id' => $dao->id),
ts('more'),
FALSE,
'dedupeRule.manage.action',
'DedupeRule',
$dao->id
);
$ruleGroups[$dao->contact_type][$dao->id]['used_display'] = $dedupeRuleTypes[$ruleGroups[$dao->contact_type][$dao->id]['used']];
}
$this->assign('brows', $ruleGroups);
}
/**
* Get name of edit form.
*
* @return string
* classname of edit form
*/
public function editForm() {
return 'CRM_Contact_Form_DedupeRules';
}
/**
* Get edit form name.
*
* @return string
* name of this page
*/
public function editName() {
return 'DedupeRules';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context
*/
public function userContext($mode = NULL) {
return 'civicrm/contact/deduperules';
}
/**
* @param int $id
*/
public function delete($id) {
$ruleDao = new CRM_Dedupe_DAO_Rule();
$ruleDao->dedupe_rule_group_id = $id;
$ruleDao->delete();
$rgDao = new CRM_Dedupe_DAO_RuleGroup();
$rgDao->id = $id;
if ($rgDao->find(TRUE)) {
$rgDao->delete();
CRM_Core_Session::setStatus(ts("The rule '%1' has been deleted.", array(1 => $rgDao->title)), ts('Rule Deleted'), 'success');
CRM_Utils_System::redirect(CRM_Utils_System::url($this->userContext(), 'reset=1'));
}
}
}

View file

@ -0,0 +1,102 @@
<?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
*/
class CRM_Contact_Page_ImageFile extends CRM_Core_Page {
/**
* @var int Time to live (seconds).
*
* 12 hours: 12 * 60 * 60 = 43200
*/
private $ttl = 43200;
/**
* Run page.
*
* @throws \Exception
*/
public function run() {
if (!preg_match('/^[^\/]+\.(jpg|jpeg|png|gif)$/i', $_GET['photo'])) {
CRM_Core_Error::fatal('Malformed photo name');
}
// FIXME Optimize performance of image_url query
$sql = "SELECT id FROM civicrm_contact WHERE image_url like %1;";
$params = array(
1 => array("%" . $_GET['photo'], 'String'),
);
$dao = CRM_Core_DAO::executeQuery($sql, $params);
$cid = NULL;
while ($dao->fetch()) {
$cid = $dao->id;
}
if ($cid) {
$config = CRM_Core_Config::singleton();
$fileExtension = strtolower(pathinfo($_GET['photo'], PATHINFO_EXTENSION));
$this->download(
$config->customFileUploadDir . $_GET['photo'],
'image/' . ($fileExtension == 'jpg' ? 'jpeg' : $fileExtension),
$this->ttl
);
CRM_Utils_System::civiExit();
}
else {
CRM_Core_Error::fatal('Photo does not exist');
}
}
/**
* Download image.
*
* @param string $file
* Local file path.
* @param string $mimeType
* @param int $ttl
* Time to live (seconds).
*/
protected function download($file, $mimeType, $ttl) {
if (!file_exists($file)) {
header("HTTP/1.0 404 Not Found");
return;
}
elseif (!is_readable($file)) {
header('HTTP/1.0 403 Forbidden');
return;
}
CRM_Utils_System::setHttpHeader('Expires', gmdate('D, d M Y H:i:s \G\M\T', CRM_Utils_Time::getTimeRaw() + $ttl));
CRM_Utils_System::setHttpHeader("Content-Type", $mimeType);
CRM_Utils_System::setHttpHeader("Content-Disposition", "inline; filename=\"" . basename($file) . "\"");
CRM_Utils_System::setHttpHeader("Cache-Control", "max-age=$ttl, public");
CRM_Utils_System::setHttpHeader('Pragma', 'public');
readfile($file);
}
}

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
*/
/**
* Dummy page for actions button.
*/
class CRM_Contact_Page_Inline_Actions extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$this->assign('contactId', $contactId);
$this->assign('actionsMenuList', CRM_Contact_BAO_Contact::contextMenu($contactId));
CRM_Contact_Page_View::addUrls($this, $contactId);
// also create the form element for the activity links box
$controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_ActivityLinks',
ts('Activity Links'),
NULL
);
$controller->setEmbedded(TRUE);
$controller->run();
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,117 @@
<?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
*/
/**
* Dummy page for details of address.
*/
class CRM_Contact_Page_Inline_Address extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$addressId = CRM_Utils_Request::retrieve('aid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
$address = array();
if ($addressId > 0) {
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
$entityBlock = array('id' => $addressId);
$address = CRM_Core_BAO_Address::getValues($entityBlock, FALSE, 'id');
if (!empty($address)) {
foreach ($address as $key => & $value) {
$value['location_type'] = $locationTypes[$value['location_type_id']];
}
}
}
// we just need current address block
$currentAddressBlock['address'][$locBlockNo] = array_pop($address);
if (!empty($currentAddressBlock['address'][$locBlockNo])) {
// get contact name of shared contact names
$sharedAddresses = array();
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($currentAddressBlock['address']);
foreach ($currentAddressBlock['address'] as $key => $addressValue) {
if (!empty($addressValue['master_id']) &&
!$shareAddressContactNames[$addressValue['master_id']]['is_deleted']
) {
$sharedAddresses[$key]['shared_address_display'] = array(
'address' => $addressValue['display'],
'name' => $shareAddressContactNames[$addressValue['master_id']]['name'],
);
}
}
$idValue = $currentAddressBlock['address'][$locBlockNo]['id'];
if (!empty($currentAddressBlock['address'][$locBlockNo]['master_id'])) {
$idValue = $currentAddressBlock['address'][$locBlockNo]['master_id'];
}
// add custom data of type address
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', NULL, $idValue);
// we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
$currentAddressBlock['address'][$locBlockNo]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
$this->assign("dnc_viewCustomData", NULL);
$this->assign('add', $currentAddressBlock['address'][$locBlockNo]);
$this->assign('sharedAddresses', $sharedAddresses);
}
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contactId;
$contact->find(TRUE);
$privacy = array();
foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
if (isset($contact->$name)) {
$privacy[$name] = $contact->$name;
}
}
$this->assign('contactId', $contactId);
$this->assign('locationIndex', $locBlockNo);
$this->assign('addressId', $addressId);
$this->assign('privacy', $privacy);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,75 @@
<?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
*/
/**
* Dummy page for details of communication preferences.
*/
class CRM_Contact_Page_Inline_CommunicationPreferences extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$params = array('id' => $contactId);
$defaults = array();
CRM_Contact_BAO_Contact::getValues($params, $defaults);
$defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
$communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
if (!empty($communicationStyle)) {
if (!empty($defaults['communication_style_id'])) {
$defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
}
else {
// Make sure the field is displayed as long as it is active, even if it is unset for this contact.
$defaults['communication_style_display'] = '';
}
}
$this->assign('contactId', $contactId);
$this->assign($defaults);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,71 @@
<?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
*/
/**
* Page to display contact information on top of summary.
*/
class CRM_Contact_Page_Inline_ContactInfo extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$params = array('id' => $contactId);
$defaults = array();
CRM_Contact_BAO_Contact::getValues($params, $defaults);
//get the current employer name
if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
if (!empty($defaults['employer_id']) && !empty($defaults['organization_name'])) {
$defaults['current_employer'] = $defaults['organization_name'];
$defaults['current_employer_id'] = $defaults['employer_id'];
}
}
$this->assign('contactId', $contactId);
$this->assign($defaults);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

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
*/
/**
* Page to display contact name on top of the summary.
*/
class CRM_Contact_Page_Inline_ContactName extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'is_deleted');
$this->assign('contactId', $contactId);
$title = CRM_Contact_Page_View::setTitle($contactId, $isDeleted);
$this->assign('title', $title);
// Check if this is default domain contact CRM-10482
$this->assign('domainContact', CRM_Contact_BAO_Contact::checkDomainContact($contactId));
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,78 @@
<?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
*/
/**
* This page displays custom data during inline edit.
*/
class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
$cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
//custom groups Inline
$entityType = CRM_Contact_BAO_Contact::getContactType($contactId);
$entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
$groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, NULL, $contactId,
$cgId, $entitySubType
);
$details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $contactId);
//get the fields of single custom group record
if ($customRecId == 1) {
$fields = reset($details[$cgId]);
}
else {
$fields = CRM_Utils_Array::value($customRecId, $details[$cgId]);
}
$this->assign('cgcount', $cgcount);
$this->assign('customRecId', $customRecId);
$this->assign('contactId', $contactId);
$this->assign('customGroupId', $cgId);
$this->assign_by_ref('cd_edit', $fields);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,69 @@
<?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
*/
/**
* Dummy page for details of demographics.
*/
class CRM_Contact_Page_Inline_Demographics extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$params = array('id' => $contactId);
$defaults = array();
CRM_Contact_BAO_Contact::getValues($params, $defaults);
if (!empty($defaults['gender_id'])) {
$gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
$defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
}
$this->assignFieldMetadataToTemplate('Contact');
$this->assign('contactId', $contactId);
$this->assign($defaults);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

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
*/
/**
* Dummy page for details of Email.
*/
class CRM_Contact_Page_Inline_Email extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
$entityBlock = array('contact_id' => $contactId);
$emails = CRM_Core_BAO_Email::getValues($entityBlock);
if (!empty($emails)) {
foreach ($emails as &$value) {
$value['location_type'] = $locationTypes[$value['location_type_id']];
}
}
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contactId;
$contact->find(TRUE);
$privacy = array();
foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
if (isset($contact->$name)) {
$privacy[$name] = $contact->$name;
}
}
$this->assign('contactId', $contactId);
$this->assign('email', $emails);
$this->assign('privacy', $privacy);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,70 @@
<?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
*/
/**
* Dummy page for details for IM.
*/
class CRM_Contact_Page_Inline_IM extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
$IMProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
$entityBlock = array('contact_id' => $contactId);
$ims = CRM_Core_BAO_IM::getValues($entityBlock);
if (!empty($ims)) {
foreach ($ims as $key => & $value) {
$value['location_type'] = $locationTypes[$value['location_type_id']];
$value['provider'] = $IMProviders[$value['provider_id']];
}
}
$this->assign('contactId', $contactId);
$this->assign('im', $ims);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,68 @@
<?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
*/
/**
* Dummy page for details for OpenID.
*/
class CRM_Contact_Page_Inline_OpenID extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
$entityBlock = array('contact_id' => $contactId);
$openids = CRM_Core_BAO_OpenID::getValues($entityBlock);
if (!empty($openids)) {
foreach ($openids as $key => & $value) {
$value['location_type'] = $locationTypes[$value['location_type_id']];
}
}
$this->assign('contactId', $contactId);
$this->assign('openid', $openids);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,81 @@
<?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
*/
/**
* Dummy page for details of Phone.
*/
class CRM_Contact_Page_Inline_Phone extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$entityBlock = array('contact_id' => $contactId);
$phones = CRM_Core_BAO_Phone::getValues($entityBlock);
if (!empty($phones)) {
foreach ($phones as $key => & $value) {
$value['location_type'] = $locationTypes[$value['location_type_id']];
$value['phone_type'] = $phoneTypes[$value['phone_type_id']];
}
}
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contactId;
$contact->find(TRUE);
$privacy = array();
foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
if (isset($contact->$name)) {
$privacy[$name] = $contact->$name;
}
}
$this->assign('contactId', $contactId);
$this->assign('phone', $phones);
$this->assign('privacy', $privacy);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,68 @@
<?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
*/
/**
* Dummy page for details of website.
*/
class CRM_Contact_Page_Inline_Website extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
$params = array('contact_id' => $contactId);
$websites = CRM_Core_BAO_Website::getValues($params, CRM_Core_DAO::$_nullArray);
if (!empty($websites)) {
foreach ($websites as $key => & $value) {
$value['website_type'] = $websiteTypes[$value['website_type_id']];
}
}
$this->assign('contactId', $contactId);
$this->assign('website', $websites);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
}

View file

@ -0,0 +1,169 @@
<?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
*/
/**
* Main page for viewing all Saved searches.
*/
class CRM_Contact_Page_SavedSearch extends CRM_Core_Page {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Delete a saved search.
*
* @param int $id
* Id of saved search.
*/
public function delete($id) {
// first delete the group associated with this saved search
$group = new CRM_Contact_DAO_Group();
$group->saved_search_id = $id;
if ($group->find(TRUE)) {
CRM_Contact_BAO_Group::discard($group->id);
}
$savedSearch = new CRM_Contact_DAO_SavedSearch();
$savedSearch->id = $id;
$savedSearch->is_active = 0;
$savedSearch->save();
}
/**
* Browse all saved searches.
*
* @return mixed
* content of the parents run method
*/
public function browse() {
$rows = array();
$savedSearch = new CRM_Contact_DAO_SavedSearch();
$savedSearch->is_active = 1;
$savedSearch->selectAdd();
$savedSearch->selectAdd('id, form_values');
$savedSearch->find();
$properties = array('id', 'name', 'description');
while ($savedSearch->fetch()) {
// get name and description from group object
$group = new CRM_Contact_DAO_Group();
$group->saved_search_id = $savedSearch->id;
if ($group->find(TRUE)) {
$permissions = CRM_Contact_BAO_Group::checkPermission($group->id, TRUE);
if (!CRM_Utils_System::isNull($permissions)) {
$row = array();
$row['name'] = $group->title;
$row['description'] = $group->description;
$row['id'] = $savedSearch->id;
$formValues = unserialize($savedSearch->form_values);
$query = new CRM_Contact_BAO_Query($formValues);
$row['query_detail'] = $query->qill();
$action = array_sum(array_keys(self::links()));
$action = $action & CRM_Core_Action::mask($permissions);
$row['action'] = CRM_Core_Action::formLink(
self::links(),
$action,
array('id' => $row['id']),
ts('more'),
FALSE,
'savedSearch.manage.action',
'SavedSearch',
$row['id']
);
$rows[] = $row;
}
}
}
$this->assign('rows', $rows);
return parent::run();
}
/**
* Run this page (figure out the action needed and perform it).
*/
public function run() {
$action = CRM_Utils_Request::retrieve('action', 'String',
$this, FALSE, 'browse'
);
$this->assign('action', $action);
if ($action & CRM_Core_Action::DELETE) {
$id = CRM_Utils_Request::retrieve('id', 'Positive',
$this, TRUE
);
$this->delete($id);
}
$this->browse();
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public static function &links() {
if (!(self::$_links)) {
$deleteExtra = ts('Do you really want to remove this Smart Group?');
self::$_links = array(
CRM_Core_Action::VIEW => array(
'name' => ts('Search'),
'url' => 'civicrm/contact/search/advanced',
'qs' => 'reset=1&force=1&ssID=%%id%%',
'title' => ts('Search'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/contact/search/saved',
'qs' => 'action=delete&id=%%id%%',
'extra' => 'onclick="return confirm(\'' . $deleteExtra . '\');"',
),
);
}
return self::$_links;
}
}

View file

@ -0,0 +1,53 @@
<?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
*/
/**
* This is a dummy class that does nothing at the moment.
*
* The template is used primarily for displaying result page
* of tasks performed on contacts. Contacts are searched/selected
* and then subjected to Tasks/Actions.
*/
class CRM_Contact_Page_Task extends CRM_Core_Page {
/**
* Returns the page title.
*
* @return string
* the title of the page
*/
public function getTitle() {
return "Task Results";
}
}

View file

@ -0,0 +1,375 @@
<?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
*/
/**
* Main page for viewing contact.
*/
class CRM_Contact_Page_View extends CRM_Core_Page {
/**
* The id of the object being viewed (note/relationship etc)
*
* @int
*/
protected $_id;
/**
* The contact id of the contact being viewed
*
* @int
*/
protected $_contactId;
/**
* The action that we are performing
*
* @string
*/
protected $_action;
/**
* The permission we have on this contact
*
* @string
*/
protected $_permission;
/**
* Heart of the viewing process.
*
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
// process url params
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->assign('id', $this->_id);
$qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
//validate the qfKey
if (!CRM_Utils_Rule::qfKey($qfKey)) {
$qfKey = NULL;
}
$this->assign('searchKey', $qfKey);
// retrieve the group contact id, so that we can get contact id
$gcid = CRM_Utils_Request::retrieve('gcid', 'Positive', $this);
if (!$gcid) {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
}
else {
$this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_GroupContact', $gcid, 'contact_id');
}
if (!$this->_contactId) {
CRM_Core_Error::statusBounce(
ts('We could not find a contact id.'),
CRM_Utils_System::url('civicrm/dashboard', 'reset=1')
);
}
// ensure that the id does exist
if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'id') != $this->_contactId) {
CRM_Core_Error::statusBounce(
ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId)),
CRM_Utils_System::url('civicrm/dashboard', 'reset=1')
);
}
$this->assign('contactId', $this->_contactId);
// see if we can get prev/next positions from qfKey
$navContacts = array(
'prevContactID' => NULL,
'prevContactName' => NULL,
'nextContactID' => NULL,
'nextContactName' => NULL,
'nextPrevError' => 0,
);
if ($qfKey) {
$pos = CRM_Core_BAO_PrevNextCache::getPositions("civicrm search $qfKey",
$this->_contactId,
$this->_contactId
);
$found = FALSE;
if (isset($pos['prev'])) {
$navContacts['prevContactID'] = $pos['prev']['id1'];
$navContacts['prevContactName'] = $pos['prev']['data'];
$found = TRUE;
}
if (isset($pos['next'])) {
$navContacts['nextContactID'] = $pos['next']['id1'];
$navContacts['nextContactName'] = $pos['next']['data'];
$found = TRUE;
}
$context = CRM_Utils_Array::value('context', $_GET);
if (!$found) {
// seems like we did not find any contacts
// maybe due to bug CRM-9096
// however we should account for 1 contact results (which dont have prev next)
if (!$pos['foundEntry']) {
$navContacts['nextPrevError'] = 1;
}
}
elseif ($context) {
$this->assign('context', $context);
CRM_Utils_System::appendBreadCrumb(array(
array(
'title' => ts('Search Results'),
'url' => CRM_Utils_System::url("civicrm/contact/search/$context", array('qfKey' => $qfKey)),
),
));
}
}
$this->assign($navContacts);
$path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('View Contact'), 'url' => $path)));
if ($image_URL = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'image_URL')) {
$this->assign("imageURL", CRM_Utils_File::getImageURL($image_URL));
}
// also store in session for future use
$session = CRM_Core_Session::singleton();
$session->set('view.id', $this->_contactId);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
// check logged in user permission
self::checkUserPermission($this);
list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = self::getContactDetails($this->_contactId);
$this->assign('displayName', $displayName);
$this->set('contactType', $contactType);
// note: there could still be multiple subtypes. We just trimming the outer separator.
$this->set('contactSubtype', trim($contactSubtype, CRM_Core_DAO::VALUE_SEPARATOR));
// add to recently viewed block
$isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'is_deleted');
$recentOther = array(
'imageUrl' => $contactImageUrl,
'subtype' => $contactSubtype,
'isDeleted' => $isDeleted,
);
if (CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$this->_contactId}");
}
if (($session->get('userID') != $this->_contactId) && CRM_Core_Permission::check('delete contacts')
&& !$isDeleted
) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/delete', "reset=1&delete=1&cid={$this->_contactId}");
}
CRM_Utils_Recent::add($displayName,
CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactId}"),
$this->_contactId,
$contactType,
$this->_contactId,
$displayName,
$recentOther
);
$this->assign('isDeleted', $isDeleted);
// set page title
$title = self::setTitle($this->_contactId, $isDeleted);
$this->assign('title', $title);
// Check if this is default domain contact CRM-10482
if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactId)) {
$this->assign('domainContact', TRUE);
}
else {
$this->assign('domainContact', FALSE);
}
// Add links for actions menu
self::addUrls($this, $this->_contactId);
if ($contactType == 'Organization' &&
CRM_Core_Permission::check('administer Multiple Organizations') &&
Civi::settings()->get('is_enabled')) {
//check is any relationship between the organization and groups
$groupOrg = CRM_Contact_BAO_GroupOrganization::hasGroupAssociated($this->_contactId);
if ($groupOrg) {
$groupOrganizationUrl = CRM_Utils_System::url('civicrm/group',
"reset=1&oid={$this->_contactId}"
);
$this->assign('groupOrganizationUrl', $groupOrganizationUrl);
}
}
}
/**
* Get meta details of the contact.
*
* @param int $contactId
*
* @return array
* contact fields in fixed order
*/
public static function getContactDetails($contactId) {
return list($displayName,
$contactImage,
$contactType,
$contactSubtype,
$contactImageUrl
) = CRM_Contact_BAO_Contact::getDisplayAndImage($contactId,
TRUE,
TRUE
);
}
/**
* @param $page
* @param int $contactID
*/
public static function checkUserPermission($page, $contactID = NULL) {
// check for permissions
$page->_permission = NULL;
if (!$contactID) {
$contactID = $page->_contactId;
}
// automatically grant permissin for users on their own record. makes
// things easier in dashboard
$session = CRM_Core_Session::singleton();
if ($session->get('userID') == $contactID && CRM_Core_Permission::check('edit my contact')) {
$page->assign('permission', 'edit');
$page->_permission = CRM_Core_Permission::EDIT;
// deleted contacts stuff should be (at best) only viewable
}
elseif (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'is_deleted') and CRM_Core_Permission::check('access deleted contacts')) {
$page->assign('permission', 'view');
$page->_permission = CRM_Core_Permission::VIEW;
}
elseif (CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) {
$page->assign('permission', 'edit');
$page->_permission = CRM_Core_Permission::EDIT;
}
elseif (CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::VIEW)) {
$page->assign('permission', 'view');
$page->_permission = CRM_Core_Permission::VIEW;
}
else {
$session->pushUserContext(CRM_Utils_System::url('civicrm', 'reset=1'));
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to view this contact.'));
}
}
/**
* @param int $contactId
* @param bool $isDeleted
*
* @return string
*/
public static function setTitle($contactId, $isDeleted = FALSE) {
static $contactDetails;
$displayName = $contactImage = NULL;
if (!isset($contactDetails[$contactId])) {
list($displayName, $contactImage) = self::getContactDetails($contactId);
$contactDetails[$contactId] = array(
'displayName' => $displayName,
'contactImage' => $contactImage,
'isDeceased' => (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'is_deceased'),
);
}
else {
$displayName = $contactDetails[$contactId]['displayName'];
$contactImage = $contactDetails[$contactId]['contactImage'];
}
// set page title
$title = "{$contactImage} {$displayName}";
if ($contactDetails[$contactId]['isDeceased']) {
$title .= ' <span class="crm-contact-deceased">(deceased)</span>';
}
if ($isDeleted) {
$title = "<del>{$title}</del>";
}
// Inline-edit places its own title on the page
CRM_Utils_System::setTitle('CiviCRM', '<span id="crm-remove-title" style="display:none">CiviCRM</span>');
return $title;
}
/**
* Add urls for display in the actions menu.
* @param CRM_Core_Page $obj
* @param int $cid
*/
public static function addUrls(&$obj, $cid) {
$uid = CRM_Core_BAO_UFMatch::getUFId($cid);
if ($uid) {
$userRecordUrl = CRM_Core_Config::singleton()->userSystem->getUserRecordUrl($cid);
$obj->assign('userRecordUrl', $userRecordUrl);
$obj->assign('userRecordId', $uid);
}
elseif (CRM_Core_Config::singleton()->userSystem->checkPermissionAddUser()) {
$userAddUrl = CRM_Utils_System::url('civicrm/contact/view/useradd', 'reset=1&action=add&cid=' . $cid);
$obj->assign('userAddUrl', $userAddUrl);
}
if (CRM_Core_Permission::check('access Contact Dashboard')) {
$dashboardURL = CRM_Utils_System::url('civicrm/user',
"reset=1&id={$cid}"
);
$obj->assign('dashboardURL', $dashboardURL);
}
// See if other modules want to add links to the activtity bar
$hookLinks = array();
CRM_Utils_Hook::links('view.contact.activity',
'Contact',
$cid,
$hookLinks
);
if (is_array($hookLinks)) {
$obj->assign('hookLinks', $hookLinks);
}
}
}

View file

@ -0,0 +1,108 @@
<?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
*/
class CRM_Contact_Page_View_ContactSmartGroup extends CRM_Core_Page {
/**
* @var int contact id
*/
public $_contactId;
/**
* called when action is browse.
*
*/
public function browse() {
$in = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added');
// keep track of all 'added' contact groups so we can remove them from the smart group
// section
$staticGroups = array();
if (!empty($in)) {
foreach ($in as $group) {
$staticGroups[$group['group_id']] = 1;
}
}
$allGroup = CRM_Contact_BAO_GroupContactCache::contactGroup($this->_contactId);
$this->assign('groupSmart', NULL);
$this->assign('groupParent', NULL);
if (!empty($allGroup)) {
$smart = $parent = array();
foreach ($allGroup['group'] as $group) {
// delete all smart groups which are also in static groups
if (isset($staticGroups[$group['id']])) {
continue;
}
if (empty($group['children'])) {
$smart[] = $group;
}
else {
$parent[] = $group;
}
}
if (!empty($smart)) {
$this->assign_by_ref('groupSmart', $smart);
}
if (!empty($parent)) {
$this->assign_by_ref('groupParent', $parent);
}
}
}
public function preProcess() {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
// check logged in url permission
CRM_Contact_Page_View::checkUserPermission($this);
}
/**
* the main function that is called
* when the page loads, it decides the which action has
* to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
$this->browse();
return parent::run();
}
}

View file

@ -0,0 +1,177 @@
<?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
*/
/**
* Page for displaying custom data.
*/
class CRM_Contact_Page_View_CustomData extends CRM_Core_Page {
/**
* The id of the object being viewed (note/relationship etc).
*
* @int
*/
public $_groupId;
/**
* Class constructor.
*
* @return CRM_Contact_Page_View_CustomData
*/
public function __construct() {
parent::__construct();
}
/**
* Add a few specific things to view contact.
*/
public function preProcess() {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
// check logged in url permission
CRM_Contact_Page_View::checkUserPermission($this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
$this->_groupId = CRM_Utils_Request::retrieve('gid', 'Positive', $this, TRUE);
$this->assign('groupId', $this->_groupId);
$this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this, FALSE);
$this->_cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE);
$this->_recId = CRM_Utils_Request::retrieve('recId', 'Positive', $this, FALSE);
}
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
*/
public function run() {
$this->preProcess();
//set the userContext stack
$doneURL = 'civicrm/contact/view';
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url($doneURL, 'action=browse&selectedChild=custom_' . $this->_groupId), FALSE);
// Get permission detail - view or edit.
// use a contact id specific function which gives us much better granularity
// CRM-12646
$editCustomData = CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT);
$this->assign('editCustomData', $editCustomData);
// Allow to edit own custom data CRM-5518.
$editOwnCustomData = FALSE;
if ($session->get('userID') == $this->_contactId) {
$editOwnCustomData = TRUE;
}
$this->assign('editOwnCustomData', $editOwnCustomData);
if ($this->_action == CRM_Core_Action::BROWSE) {
$displayStyle = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup',
$this->_groupId,
'style'
);
if ($this->_multiRecordDisplay != 'single') {
$id = "custom_{$this->_groupId}";
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_groupId, 'table_name');
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent($id, $this->_contactId, $tableName);
}
if ($displayStyle === 'Tab with table' && $this->_multiRecordDisplay != 'single') {
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
$this->_contactId,
'contact_type'
);
$this->assign('displayStyle', 'tableOriented');
// here the multi custom data listing code will go
$multiRecordFieldListing = TRUE;
$page = new CRM_Profile_Page_MultipleRecordFieldsListing();
$page->set('contactId', $this->_contactId);
$page->set('customGroupId', $this->_groupId);
$page->set('action', CRM_Core_Action::BROWSE);
$page->set('multiRecordFieldListing', $multiRecordFieldListing);
$page->set('pageViewType', 'customDataView');
$page->set('contactType', $ctype);
$page->_headersOnly = TRUE;
$page->run();
}
else {
//Custom Groups Inline
$entityType = CRM_Contact_BAO_Contact::getContactType($this->_contactId);
$entitySubType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId);
$recId = NULL;
if ($this->_multiRecordDisplay == 'single') {
$groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupId);
CRM_Utils_System::setTitle(ts('View %1 Record', array(1 => $groupTitle)));
$groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, NULL, $this->_contactId,
$this->_groupId, $entitySubType, NULL, TRUE, NULL, FALSE, TRUE, $this->_cgcount
);
$recId = $this->_recId;
$this->assign('multiRecordDisplay', $this->_multiRecordDisplay);
$this->assign('skipTitle', 1);
}
else {
$groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, NULL, $this->_contactId,
$this->_groupId, $entitySubType
);
}
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, $recId, $this->_contactId);
}
}
else {
$controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_CustomData',
ts('Custom Data'),
$this->_action
);
$controller->setEmbedded(TRUE);
$controller->set('tableId', $this->_contactId);
$controller->set('groupId', $this->_groupId);
$controller->set('entityType', CRM_Contact_BAO_Contact::getContactType($this->_contactId));
$controller->set('entitySubType', CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ','));
$controller->process();
$controller->run();
}
return parent::run();
}
}

View file

@ -0,0 +1,192 @@
<?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
*/
class CRM_Contact_Page_View_GroupContact extends CRM_Core_Page {
/**
* Called when action is browse.
*/
public function browse() {
$count = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, NULL, NULL, TRUE, FALSE, FALSE, TRUE, NULL, TRUE);
$in = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added', NULL, FALSE, FALSE, FALSE, TRUE, NULL, TRUE);
$pending = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Pending', NULL, FALSE, FALSE, FALSE, TRUE, NULL, TRUE);
$out = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Removed', NULL, FALSE, FALSE, FALSE, TRUE, NULL, TRUE);
// keep track of all 'added' contact groups so we can remove them from the smart group
// section
$staticGroups = array();
if (!empty($in)) {
foreach ($in as $group) {
$staticGroups[$group['group_id']] = 1;
}
}
$this->assign('groupCount', $count);
$this->assign_by_ref('groupIn', $in);
$this->assign_by_ref('groupPending', $pending);
$this->assign_by_ref('groupOut', $out);
// get the info on contact smart groups
$contactSmartGroupSettings = Civi::settings()->get('contact_smart_group_display');
$this->assign('contactSmartGroupSettings', $contactSmartGroupSettings);
$this->ajaxResponse['tabCount'] = count($in);
}
/**
* called when action is update.
*
* @param int $groupId
*
*/
public function edit($groupId = NULL) {
$controller = new CRM_Core_Controller_Simple(
'CRM_Contact_Form_GroupContact',
ts('Contact\'s Groups'),
$this->_action
);
$controller->setEmbedded(TRUE);
// set the userContext stack
$session = CRM_Core_Session::singleton();
$session->pushUserContext(
CRM_Utils_System::url(
'civicrm/contact/view',
"action=browse&selectedChild=group&cid={$this->_contactId}"
),
FALSE
);
$controller->reset();
$controller->set('contactId', $this->_contactId);
$controller->set('groupId', $groupId);
$controller->process();
$controller->run();
}
public function preProcess() {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
// check logged in url permission
CRM_Contact_Page_View::checkUserPermission($this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
}
/**
* the main function that is called
* when the page loads, it decides the which action has
* to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
if ($this->_action == CRM_Core_Action::DELETE) {
$groupContactId = CRM_Utils_Request::retrieve('gcid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
$status = CRM_Utils_Request::retrieve('st', 'String', CRM_Core_DAO::$_nullObject, TRUE);
if (is_numeric($groupContactId) && $status) {
$this->del($groupContactId, $status, $this->_contactId);
}
$session = CRM_Core_Session::singleton();
CRM_Utils_System::redirect($session->popUserContext());
}
$this->edit(NULL, CRM_Core_Action::ADD);
$this->browse();
return parent::run();
}
/**
* Remove/ rejoin the group
*
* @param int $groupContactId
* Id of crm_group_contact.
* @param string $status
* This is the status that should be updated.
*
* $access public
* @param int $contactID
*
* @return bool
*/
public static function del($groupContactId, $status, $contactID) {
$groupId = CRM_Contact_BAO_GroupContact::getGroupId($groupContactId);
switch ($status) {
case 'i':
$groupStatus = 'Added';
break;
case 'p':
$groupStatus = 'Pending';
break;
case 'o':
$groupStatus = 'Removed';
break;
case 'd':
$groupStatus = 'Deleted';
break;
}
$groupNum = CRM_Contact_BAO_GroupContact::getContactGroup($contactID, 'Added', NULL, TRUE, TRUE);
if ($groupNum == 1 && $groupStatus == 'Removed' && Civi::settings()->get('is_enabled')) {
CRM_Core_Session::setStatus(ts('Please ensure at least one contact group association is maintained.'), ts('Could Not Remove'));
return FALSE;
}
$ids = array($contactID);
$method = 'Admin';
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID == $contactID) {
$method = 'Web';
}
CRM_Contact_BAO_GroupContact::removeContactsFromGroup($ids, $groupId, $method, $groupStatus);
}
}

View file

@ -0,0 +1,102 @@
<?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
*/
class CRM_Contact_Page_View_Log extends CRM_Core_Page {
/**
* Called when action is browse.
*
* @return null
*/
public function browse() {
$loggingReport = CRM_Core_BAO_Log::useLoggingReport();
$this->assign('useLogging', $loggingReport);
if ($loggingReport) {
$this->assign('instanceUrl',
CRM_Utils_System::url("civicrm/report/instance/{$loggingReport}",
"reset=1&force=1&snippet=4&section=2&altered_contact_id_op=eq&altered_contact_id_value={$this->_contactId}&cid={$this->_contactId}", FALSE, NULL, FALSE));
return NULL;
}
$log = new CRM_Core_DAO_Log();
$log->entity_table = 'civicrm_contact';
$log->entity_id = $this->_contactId;
$log->orderBy('modified_date desc');
$log->find();
$logEntries = array();
while ($log->fetch()) {
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id);
$logEntries[] = array(
'id' => $log->modified_id,
'name' => $displayName,
'image' => $contactImage,
'date' => $log->modified_date,
);
}
$this->assign('logCount', count($logEntries));
$this->ajaxResponse['tabCount'] = count($logEntries);
$this->ajaxResponse += CRM_Contact_Form_Inline::renderFooter($this->_contactId, FALSE);
$this->assign_by_ref('log', $logEntries);
}
public function preProcess() {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
// check logged in url permission
CRM_Contact_Page_View::checkUserPermission($this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
}
/**
* the main function that is called when the page loads, it decides the which action has to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
$this->browse();
return parent::run();
}
}

View file

@ -0,0 +1,306 @@
<?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
*/
/**
* Main page for viewing Notes.
*/
class CRM_Contact_Page_View_Note extends CRM_Core_Page {
/**
* The action links for notes that we need to display for the browse screen
*
* @var array
*/
static $_links = NULL;
/**
* The action links for comments that we need to display for the browse screen
*
* @var array
*/
static $_commentLinks = NULL;
/**
* View details of a note.
*/
public function view() {
$note = new CRM_Core_DAO_Note();
$note->id = $this->_id;
if ($note->find(TRUE)) {
$values = array();
CRM_Core_DAO::storeValues($note, $values);
$values['privacy'] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Note', 'privacy', $values['privacy']);
$this->assign('note', $values);
}
$comments = CRM_Core_BAO_Note::getNoteTree($values['id'], 1);
if (!empty($comments)) {
$this->assign('comments', $comments);
}
// add attachments part
$currentAttachmentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_note', $this->_id);
$this->assign('currentAttachmentInfo', $currentAttachmentInfo);
}
/**
* called when action is browse.
*/
public function browse() {
$note = new CRM_Core_DAO_Note();
$note->entity_table = 'civicrm_contact';
$note->entity_id = $this->_contactId;
$note->orderBy('modified_date desc');
//CRM-4418, handling edit and delete separately.
$permissions = array($this->_permission);
if ($this->_permission == CRM_Core_Permission::EDIT) {
//previously delete was subset of edit
//so for consistency lets grant delete also.
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$values = array();
$links = self::links();
$action = array_sum(array_keys($links)) & $mask;
$note->find();
while ($note->fetch()) {
if (!CRM_Core_BAO_Note::getNotePrivacyHidden($note)) {
CRM_Core_DAO::storeValues($note, $values[$note->id]);
$values[$note->id]['action'] = CRM_Core_Action::formLink($links,
$action,
array(
'id' => $note->id,
'cid' => $this->_contactId,
),
ts('more'),
FALSE,
'note.selector.row',
'Note',
$note->id
);
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $note->contact_id;
$contact->find();
$contact->fetch();
$values[$note->id]['createdBy'] = $contact->display_name;
$values[$note->id]['comment_count'] = CRM_Core_BAO_Note::getChildCount($note->id);
// paper icon view for attachments part
$paperIconAttachmentInfo = CRM_Core_BAO_File::paperIconAttachment('civicrm_note', $note->id);
$values[$note->id]['attachment'] = $paperIconAttachmentInfo;
}
}
$this->assign('notes', $values);
$commentLinks = self::commentLinks();
$action = array_sum(array_keys($commentLinks)) & $mask;
$commentAction = CRM_Core_Action::formLink($commentLinks,
$action,
array(
'id' => $note->id,
'pid' => $note->entity_id,
'cid' => $note->entity_id,
),
ts('more'),
FALSE,
'note.comment.action',
'Note',
$note->id
);
$this->assign('commentAction', $commentAction);
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('note', $this->_contactId);
}
/**
* called when action is update or new.
*/
public function edit() {
$controller = new CRM_Core_Controller_Simple('CRM_Note_Form_Note', ts('Contact Notes'), $this->_action);
$controller->setEmbedded(TRUE);
// set the userContext stack
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/contact/view',
'action=browse&selectedChild=note&cid=' . $this->_contactId
);
$session->pushUserContext($url);
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean')) {
CRM_Core_BAO_Note::del($this->_id);
CRM_Utils_System::redirect($url);
}
$controller->reset();
$controller->set('entityTable', 'civicrm_contact');
$controller->set('entityId', $this->_contactId);
$controller->set('id', $this->_id);
$controller->process();
$controller->run();
}
public function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if ($this->_id && CRM_Core_BAO_Note::getNotePrivacyHidden($this->_id)) {
CRM_Core_Error::statusBounce(ts('You do not have access to this note.'));
}
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
// check logged in url permission
CRM_Contact_Page_View::checkUserPermission($this);
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
CRM_Utils_System::setTitle(ts('Notes for') . ' ' . $displayName);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
}
/**
* the main function that is called when the page loads,
* it decides the which action has to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
if ($this->_action & CRM_Core_Action::VIEW) {
$this->view();
}
elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
$this->edit();
}
elseif ($this->_action & CRM_Core_Action::DELETE) {
// we use the edit screen the confirm the delete
$this->edit();
}
$this->browse();
return parent::run();
}
/**
* Delete the note object from the db.
*/
public function delete() {
CRM_Core_BAO_Note::del($this->_id);
}
/**
* Get action links.
*
* @return array
* (reference) of action links
*/
public static function &links() {
if (!(self::$_links)) {
$deleteExtra = ts('Are you sure you want to delete this note?');
self::$_links = array(
CRM_Core_Action::VIEW => array(
'name' => ts('View'),
'url' => 'civicrm/contact/view/note',
'qs' => 'action=view&reset=1&cid=%%cid%%&id=%%id%%&selectedChild=note',
'title' => ts('View Note'),
),
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/contact/view/note',
'qs' => 'action=update&reset=1&cid=%%cid%%&id=%%id%%&selectedChild=note',
'title' => ts('Edit Note'),
),
CRM_Core_Action::ADD => array(
'name' => ts('Comment'),
'url' => 'civicrm/contact/view/note',
'qs' => 'action=add&reset=1&cid=%%cid%%&parentId=%%id%%&selectedChild=note',
'title' => ts('Add Comment'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/contact/view/note',
'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%&selectedChild=note',
'title' => ts('Delete Note'),
),
);
}
return self::$_links;
}
/**
* Get action links for comments.
*
* @return array
* (reference) of action links
*/
public static function &commentLinks() {
if (!(self::$_commentLinks)) {
self::$_commentLinks = array(
CRM_Core_Action::VIEW => array(
'name' => ts('View'),
'url' => 'civicrm/contact/view/note',
'qs' => 'action=view&reset=1&cid=%%cid%%&id={id}&selectedChild=note',
'title' => ts('View Comment'),
),
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/contact/view/note',
'qs' => 'action=update&reset=1&cid=%%cid%%&id={id}&parentId=%%pid%%&selectedChild=note',
'title' => ts('Edit Comment'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/contact/view/note',
'qs' => 'action=delete&reset=1&cid=%%cid%%&id={id}&selectedChild=note',
'title' => ts('Delete Comment'),
),
);
}
return self::$_commentLinks;
}
}

View file

@ -0,0 +1,70 @@
<?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
*/
/**
* Main page for viewing contact.
*/
class CRM_Contact_Page_View_Print extends CRM_Contact_Page_View_Summary {
/**
* Heart of the viewing process.
*
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function run() {
$this->_print = CRM_Core_Smarty::PRINT_PAGE;
$this->preProcess();
$this->view();
return parent::run();
}
/**
* View summary details of a contact.
*/
public function view() {
$params = array();
$defaults = array();
$ids = array();
$params['id'] = $params['contact_id'] = $this->_contactId;
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, $ids);
$this->assign('pageTitle', $contact->sort_name);
return parent::view();
}
}

View file

@ -0,0 +1,298 @@
<?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
*/
class CRM_Contact_Page_View_Relationship extends CRM_Core_Page {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Casid set if called from case context.
*
* @var int
*/
public $_caseId = NULL;
public $_permission = NULL;
public $_contactId = NULL;
/**
* View details of a relationship.
*/
public function view() {
$viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, NULL, NULL, NULL, $this->_id);
//To check whether selected contact is a contact_id_a in
//relationship type 'a_b' in relationship table, if yes then
//revert the permissionship text in template
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->id = $viewRelationship[$this->_id]['id'];
if ($relationship->find(TRUE)) {
if (($viewRelationship[$this->_id]['rtype'] == 'a_b') && ($this->_contactId == $relationship->contact_id_a)) {
$this->assign("is_contact_id_a", TRUE);
}
}
$relType = $viewRelationship[$this->_id]['civicrm_relationship_type_id'];
$this->assign('viewRelationship', $viewRelationship);
$employerId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'employer_id');
$this->assign('isCurrentEmployer', FALSE);
$relTypes = CRM_Utils_Array::index(array('name_a_b'), CRM_Core_PseudoConstant::relationshipType('name'));
if ($viewRelationship[$this->_id]['employer_id'] == $this->_contactId) {
$this->assign('isCurrentEmployer', TRUE);
}
elseif ($relType == $relTypes['Employee of']['id'] &&
($viewRelationship[$this->_id]['cid'] == $employerId)
) {
// make sure we are viewing employee of relationship
$this->assign('isCurrentEmployer', TRUE);
}
$viewNote = CRM_Core_BAO_Note::getNote($this->_id);
$this->assign('viewNote', $viewNote);
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Relationship', NULL, $this->_id, 0, $relType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
$rType = CRM_Utils_Array::value('rtype', $viewRelationship[$this->_id]);
// add viewed contribution to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/rel',
"action=view&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&context=home"
);
$session = CRM_Core_Session::singleton();
$recentOther = array();
if (($session->get('userID') == $this->_contactId) ||
CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)
) {
$recentOther = array(
'editUrl' => CRM_Utils_System::url('civicrm/contact/view/rel',
"action=update&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&rtype={$rType}&context=home"
),
'deleteUrl' => CRM_Utils_System::url('civicrm/contact/view/rel',
"action=delete&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&rtype={$rType}&context=home"
),
);
}
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
CRM_Utils_System::setTitle(ts('View Relationship for') . ' ' . $displayName);
$title = $displayName . ' (' . $viewRelationship[$this->_id]['relation'] . ' ' . CRM_Contact_BAO_Contact::displayName($viewRelationship[$this->_id]['cid']) . ')';
// add the recently viewed Relationship
CRM_Utils_Recent::add($title,
$url,
$viewRelationship[$this->_id]['id'],
'Relationship',
$this->_contactId,
NULL,
$recentOther
);
}
/**
* called when action is browse.
*
*/
public function browse() {
// do nothing :) we are using datatable for rendering relationship selectors
}
/**
* called when action is update or new.
*
*/
public function edit() {
$controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_Relationship', ts('Contact Relationships'), $this->_action);
$controller->setEmbedded(TRUE);
// set the userContext stack
$session = CRM_Core_Session::singleton();
// if this is called from case view, we need to redirect back to same page
if ($this->_caseId) {
$url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&cid={$this->_contactId}&id={$this->_caseId}");
}
else {
$url = CRM_Utils_System::url('civicrm/contact/view', "action=browse&selectedChild=rel&reset=1&cid={$this->_contactId}");
}
$session->pushUserContext($url);
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean')) {
if ($this->_caseId) {
//create an activity for case role removal.CRM-4480
CRM_Case_BAO_Case::createCaseRoleActivity($this->_caseId, $this->_id);
CRM_Core_Session::setStatus(ts('Case Role has been deleted successfully.'), ts('Record Deleted'), 'success');
}
// delete relationship
CRM_Contact_BAO_Relationship::del($this->_id);
CRM_Utils_System::redirect($url);
}
$controller->set('contactId', $this->_contactId);
$controller->set('id', $this->_id);
$controller->process();
$controller->run();
}
public function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
// check logged in url permission
CRM_Contact_Page_View::checkUserPermission($this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
}
/**
* the main function that is called when the page loads,
* it decides the which action has to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
$this->setContext();
$this->_caseId = CRM_Utils_Request::retrieve('caseID', 'Integer', $this);
if ($this->_action & CRM_Core_Action::VIEW) {
$this->view();
}
elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
$this->edit();
}
// if this is called from case view, suppress browse relationships form
else {
$this->browse();
}
return parent::run();
}
public function setContext() {
$context = CRM_Utils_Request::retrieve('context', 'String',
$this, FALSE, 'search'
);
if ($context == 'dashboard') {
$cid = CRM_Utils_Request::retrieve('cid', 'Integer',
$this, FALSE
);
$url = CRM_Utils_System::url('civicrm/user',
"reset=1&id={$cid}"
);
}
else {
$url = CRM_Utils_System::url('civicrm/contact/view', 'action=browse&selectedChild=rel');
}
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}
/**
* called to delete the relationship of a contact.
*
*/
public function delete() {
// calls a function to delete relationship
CRM_Contact_BAO_Relationship::del($this->_id);
}
/**
* Get action links.
*
* @return array
* (reference) of action links
*/
public static function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::VIEW => array(
'name' => ts('View'),
'url' => 'civicrm/contact/view/rel',
'qs' => 'action=view&reset=1&cid=%%cid%%&id=%%id%%&rtype=%%rtype%%&selectedChild=rel',
'title' => ts('View Relationship'),
),
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/contact/view/rel',
'qs' => 'action=update&reset=1&cid=%%cid%%&id=%%id%%&rtype=%%rtype%%',
'title' => ts('Edit Relationship'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Relationship'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Relationship'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/contact/view/rel',
'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%&rtype=%%rtype%%',
'title' => ts('Delete Relationship'),
),
// FIXME: Not sure what to put as the key.
// We want to use it differently later anyway (see CRM_Contact_BAO_Relationship::getRelationship). NONE should make it hidden by default.
CRM_Core_Action::NONE => array(
'name' => ts('Manage Case'),
'url' => 'civicrm/contact/view/case',
'qs' => 'action=view&reset=1&cid=%%clientid%%&id=%%caseid%%',
'title' => ts('Manage Case'),
),
);
}
return self::$_links;
}
}

View file

@ -0,0 +1,431 @@
<?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
*/
/**
* Main page for viewing contact.
*/
class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
/**
* Heart of the viewing process.
*
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
parent::preProcess();
// actions buttom contextMenu
$menuItems = CRM_Contact_BAO_Contact::contextMenu($this->_contactId);
$this->assign('actionsMenuList', $menuItems);
//retrieve inline custom data
$entityType = $this->get('contactType');
if ($entitySubType = $this->get('contactSubtype')) {
$entitySubType = explode(CRM_Core_DAO::VALUE_SEPARATOR,
trim($entitySubType, CRM_Core_DAO::VALUE_SEPARATOR)
);
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType,
NULL,
$this->_contactId,
NULL,
$entitySubType
);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_contactId);
// also create the form element for the activity links box
$controller = new CRM_Core_Controller_Simple(
'CRM_Activity_Form_ActivityLinks',
ts('Activity Links'),
NULL,
FALSE,
FALSE,
TRUE
);
$controller->setEmbedded(TRUE);
$controller->run();
}
/**
* Heart of the viewing process.
*
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function run() {
$this->preProcess();
if ($this->_action & CRM_Core_Action::UPDATE) {
$this->edit();
}
else {
$this->view();
}
return parent::run();
}
/**
* Edit name and address of a contact.
*/
public function edit() {
// set the userContext stack
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
$session->pushUserContext($url);
$controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_Contact', ts('Contact Page'), CRM_Core_Action::UPDATE);
$controller->setEmbedded(TRUE);
$controller->process();
return $controller->run();
}
/**
* View summary details of a contact.
*/
public function view() {
// Add js for tabs, in-place editing, and jstree for tags
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js', 2, 'html-header')
->addStyleFile('civicrm', 'css/contactSummary.css', 2, 'html-header')
->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')
->addSetting(array(
'summaryPrint' => array('mode' => $this->_print),
'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary')),
));
$this->assign('summaryPrint', $this->_print);
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
$session->pushUserContext($url);
$this->assignFieldMetadataToTemplate('Contact');
$params = array();
$defaults = array();
$params['id'] = $params['contact_id'] = $this->_contactId;
$params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = TRUE;
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, TRUE);
// Let summary page know if outbound mail is disabled so email links can be built conditionally
$mailingBackend = Civi::settings()->get('mailing_backend');
$this->assign('mailingOutboundOption', $mailingBackend['outBound_option']);
$communicationType = array(
'phone' => array(
'type' => 'phoneType',
'id' => 'phone_type',
'daoName' => 'CRM_Core_DAO_Phone',
'fieldName' => 'phone_type_id',
),
'im' => array(
'type' => 'IMProvider',
'id' => 'provider',
'daoName' => 'CRM_Core_DAO_IM',
'fieldName' => 'provider_id',
),
'website' => array(
'type' => 'websiteType',
'id' => 'website_type',
'daoName' => 'CRM_Core_DAO_Website',
'fieldName' => 'website_type_id',
),
'address' => array('skip' => TRUE, 'customData' => 1),
'email' => array('skip' => TRUE),
'openid' => array('skip' => TRUE),
);
foreach ($communicationType as $key => $value) {
if (!empty($defaults[$key])) {
foreach ($defaults[$key] as & $val) {
CRM_Utils_Array::lookupValue($val, 'location_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')), FALSE);
if (empty($value['skip'])) {
$daoName = $value['daoName'];
$pseudoConst = $daoName::buildOptions($value['fieldName'], 'get');
CRM_Utils_Array::lookupValue($val, $value['id'], $pseudoConst, FALSE);
}
}
if (isset($value['customData'])) {
foreach ($defaults[$key] as $blockId => $blockVal) {
$idValue = $blockVal['id'];
if ($key == 'address') {
if (!empty($blockVal['master_id'])) {
$idValue = $blockVal['master_id'];
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree(ucfirst($key), NULL, $idValue);
// we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
$defaults[$key][$blockId]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
}
// reset template variable since that won't be of any use, and could be misleading
$this->assign("dnc_viewCustomData", NULL);
}
}
}
if (!empty($defaults['gender_id'])) {
$defaults['gender_display'] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'gender_id', $defaults['gender_id']);
}
$communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
if (!empty($communicationStyle)) {
if (!empty($defaults['communication_style_id'])) {
$defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
}
else {
// Make sure the field is displayed as long as it is active, even if it is unset for this contact.
$defaults['communication_style_display'] = '';
}
}
// to make contact type label available in the template -
$contactType = array_key_exists('contact_sub_type', $defaults) ? $defaults['contact_sub_type'] : $defaults['contact_type'];
$defaults['contact_type_label'] = CRM_Contact_BAO_ContactType::contactTypePairs(TRUE, $contactType, ', ');
// get contact tags
$contactTags = CRM_Core_BAO_EntityTag::getContactTags($this->_contactId);
if (!empty($contactTags)) {
$defaults['contactTag'] = $contactTags;
$defaults['allTags'] = CRM_Core_BAO_Tag::getTagsUsedFor('civicrm_contact', FALSE);
}
$defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
//Show blocks only if they are visible in edit form
$this->_editOptions = CRM_Core_BAO_Setting::valueOptions(
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_edit_options'
);
foreach ($this->_editOptions as $blockName => $value) {
$varName = '_show' . $blockName;
$this->$varName = $value;
$this->assign(substr($varName, 1), $this->$varName);
}
// get contact name of shared contact names
$sharedAddresses = array();
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($defaults['address']);
foreach ($defaults['address'] as $key => $addressValue) {
if (!empty($addressValue['master_id']) &&
!$shareAddressContactNames[$addressValue['master_id']]['is_deleted']
) {
$sharedAddresses[$key]['shared_address_display'] = array(
'address' => $addressValue['display'],
'name' => $shareAddressContactNames[$addressValue['master_id']]['name'],
);
}
}
$this->assign('sharedAddresses', $sharedAddresses);
//get the current employer name
if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
if ($contact->employer_id && $contact->organization_name) {
$defaults['current_employer'] = $contact->organization_name;
$defaults['current_employer_id'] = $contact->employer_id;
}
}
$defaults['external_identifier'] = $contact->external_identifier;
$this->assign($defaults);
// FIXME: when we sort out TZ isssues with DATETIME/TIMESTAMP, we can skip next query
// also assign the last modifed details
$lastModified = CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact');
$this->assign_by_ref('lastModified', $lastModified);
$allTabs = array();
$weight = 10;
$this->_viewOptions = CRM_Core_BAO_Setting::valueOptions(
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_view_options',
TRUE
);
// show the tabs only if user has generic access to CiviCRM
$accessCiviCRM = CRM_Core_Permission::check('access CiviCRM');
$changeLog = $this->_viewOptions['log'];
$this->assign_by_ref('changeLog', $changeLog);
$components = CRM_Core_Component::getEnabledComponents();
foreach ($components as $name => $component) {
if (!empty($this->_viewOptions[$name]) &&
CRM_Core_Permission::access($component->name)
) {
$elem = $component->registerTab();
// FIXME: not very elegant, probably needs better approach
// allow explicit id, if not defined, use keyword instead
if (array_key_exists('id', $elem)) {
$i = $elem['id'];
}
else {
$i = $component->getKeyword();
}
$u = $elem['url'];
//appending isTest to url for test soft credit CRM-3891.
//FIXME: hack ajax url.
$q = "reset=1&force=1&cid={$this->_contactId}";
if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
$q .= "&isTest=1";
}
$allTabs[] = array(
'id' => $i,
'url' => CRM_Utils_System::url("civicrm/contact/view/$u", $q),
'title' => $elem['title'],
'weight' => $elem['weight'],
'count' => CRM_Contact_BAO_Contact::getCountComponent($u, $this->_contactId),
'class' => 'livePage',
);
// make sure to get maximum weight, rest of tabs go after
// FIXME: not very elegant again
if ($weight < $elem['weight']) {
$weight = $elem['weight'];
}
}
}
$rest = array(
'activity' => array(
'title' => ts('Activities'),
'class' => 'livePage',
),
'rel' => array(
'title' => ts('Relationships'),
'class' => 'livePage',
),
'group' => array(
'title' => ts('Groups'),
'class' => 'ajaxForm',
),
'note' => array(
'title' => ts('Notes'),
'class' => 'livePage',
),
'tag' => array(
'title' => ts('Tags'),
),
'log' => array(
'title' => ts('Change Log'),
),
);
foreach ($rest as $k => $v) {
if ($accessCiviCRM && !empty($this->_viewOptions[$k])) {
$allTabs[] = $v + array(
'id' => $k,
'url' => CRM_Utils_System::url(
"civicrm/contact/view/$k",
"reset=1&cid={$this->_contactId}"
),
'weight' => $weight,
'count' => CRM_Contact_BAO_Contact::getCountComponent($k, $this->_contactId),
);
$weight += 10;
}
}
// now add all the custom tabs
$entityType = $this->get('contactType');
$activeGroups = CRM_Core_BAO_CustomGroup::getActiveGroups(
$entityType,
'civicrm/contact/view/cd',
$this->_contactId
);
foreach ($activeGroups as $group) {
$id = "custom_{$group['id']}";
$allTabs[] = array(
'id' => $id,
'url' => CRM_Utils_System::url($group['path'], $group['query'] . "&selectedChild=$id"),
'title' => $group['title'],
'weight' => $weight,
'count' => CRM_Contact_BAO_Contact::getCountComponent($id, $this->_contactId, $group['table_name']),
'hideCount' => !$group['is_multiple'],
'class' => 'livePage',
);
$weight += 10;
}
$context = array('contact_id' => $this->_contactId);
// see if any other modules want to add any tabs
CRM_Utils_Hook::tabs($allTabs, $this->_contactId);
CRM_Utils_Hook::tabset('civicrm/contact/view', $allTabs, $context);
$allTabs[] = array(
'id' => 'summary',
'url' => '#contact-summary',
'title' => ts('Summary'),
'weight' => 0,
);
// now sort the tabs based on weight
usort($allTabs, array('CRM_Utils_Sort', 'cmpFunc'));
$this->assign('allTabs', $allTabs);
// hook for contact summary
// ignored but needed to prevent warnings
$contentPlacement = CRM_Utils_Hook::SUMMARY_BELOW;
CRM_Utils_Hook::summary($this->_contactId, $content, $contentPlacement);
if ($content) {
$this->assign_by_ref('hookContent', $content);
$this->assign('hookContentPlacement', $contentPlacement);
}
}
/**
* @return string
*/
public function getTemplateFileName() {
if ($this->_contactId) {
$contactSubtypes = $this->get('contactSubtype') ? explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->get('contactSubtype')) : array();
// there could be multiple subtypes. We check templates for each of the subtype, and return the first one found.
foreach ($contactSubtypes as $csType) {
if ($csType) {
$templateFile = "CRM/Contact/Page/View/SubType/{$csType}.tpl";
$template = CRM_Core_Page::getTemplate();
if ($template->template_exists($templateFile)) {
return $templateFile;
}
}
}
}
return parent::getTemplateFileName();
}
}

View file

@ -0,0 +1,77 @@
<?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
*/
class CRM_Contact_Page_View_Tag extends CRM_Core_Page {
/**
* Called when action is browse.
*/
public function browse() {
$controller = new CRM_Core_Controller_Simple('CRM_Tag_Form_Tag', ts('Contact Tags'), $this->_action);
$controller->setEmbedded(TRUE);
// set the userContext stack
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', 'action=browse&selectedChild=tag'), FALSE);
$controller->reset();
$controller->set('contactId', $this->_contactId);
$controller->process();
$controller->run();
}
public function preProcess() {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
// check logged in url permission
CRM_Contact_Page_View::checkUserPermission($this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
}
/**
* the main function that is called when the page loads
* it decides the which action has to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
$this->browse();
return parent::run();
}
}

View file

@ -0,0 +1,251 @@
<?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
*/
/**
* This class is used to build User Dashboard
*/
class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
public $_contactId = NULL;
/**
* Always show public groups.
* @var bool
*/
public $_onlyPublicGroups = TRUE;
public $_edit = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* @throws Exception
*/
public function __construct() {
parent::__construct();
$check = CRM_Core_Permission::check('access Contact Dashboard');
if (!$check) {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
}
$this->_contactId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if (!$this->_contactId) {
$this->_contactId = $userID;
}
elseif ($this->_contactId != $userID) {
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::VIEW)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this contact.'));
}
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
$this->_edit = FALSE;
}
}
}
/**
* Heart of the viewing process.
*
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
if (!$this->_contactId) {
CRM_Core_Error::fatal(ts('You must be logged in to view this page.'));
}
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
$this->set('displayName', $displayName);
$this->set('contactImage', $contactImage);
CRM_Utils_System::setTitle(ts('Dashboard - %1', array(1 => $displayName)));
$this->assign('recentlyViewed', FALSE);
}
/**
* Build user dashboard.
*/
public function buildUserDashBoard() {
//build component selectors
$dashboardElements = array();
$config = CRM_Core_Config::singleton();
$this->_userOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'user_dashboard_options'
);
$components = CRM_Core_Component::getEnabledComponents();
$this->assign('contactId', $this->_contactId);
foreach ($components as $name => $component) {
$elem = $component->getUserDashboardElement();
if (!$elem) {
continue;
}
if (!empty($this->_userOptions[$name]) &&
(CRM_Core_Permission::access($component->name) ||
CRM_Core_Permission::check($elem['perm'][0])
)
) {
$userDashboard = $component->getUserDashboardObject();
$dashboardElements[] = array(
'class' => 'crm-dashboard-' . strtolower($component->name),
'sectionTitle' => $elem['title'],
'templatePath' => $userDashboard->getTemplateFileName(),
'weight' => $elem['weight'],
);
$userDashboard->run();
}
}
// CRM-16512 - Hide related contact table if user lacks permission to view self
if (!empty($this->_userOptions['Permissioned Orgs']) && CRM_Core_Permission::check('view my contact')) {
$dashboardElements[] = array(
'class' => 'crm-dashboard-permissionedOrgs',
'templatePath' => 'CRM/Contact/Page/View/RelationshipSelector.tpl',
'sectionTitle' => ts('Your Contacts / Organizations'),
'weight' => 40,
);
}
if (!empty($this->_userOptions['PCP'])) {
$dashboardElements[] = array(
'class' => 'crm-dashboard-pcp',
'templatePath' => 'CRM/Contribute/Page/PcpUserDashboard.tpl',
'sectionTitle' => ts('Personal Campaign Pages'),
'weight' => 40,
);
list($pcpBlock, $pcpInfo) = CRM_PCP_BAO_PCP::getPcpDashboardInfo($this->_contactId);
$this->assign('pcpBlock', $pcpBlock);
$this->assign('pcpInfo', $pcpInfo);
}
if (!empty($this->_userOptions['Assigned Activities'])) {
// Assigned Activities section
$dashboardElements[] = array(
'class' => 'crm-dashboard-assignedActivities',
'templatePath' => 'CRM/Activity/Page/UserDashboard.tpl',
'sectionTitle' => ts('Your Assigned Activities'),
'weight' => 5,
);
$userDashboard = new CRM_Activity_Page_UserDashboard();
$userDashboard->run();
}
usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc'));
$this->assign('dashboardElements', $dashboardElements);
// return true when 'Invoices / Credit Notes' checkbox is checked
$this->assign('invoices', $this->_userOptions['Invoices / Credit Notes']);
if (!empty($this->_userOptions['Groups'])) {
$this->assign('showGroup', TRUE);
//build group selector
$gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
$gContact->run();
}
else {
$this->assign('showGroup', FALSE);
}
}
/**
* Perform actions and display for user dashboard.
*/
public function run() {
$this->preProcess();
$this->buildUserDashBoard();
return parent::run();
}
/**
* Get action links.
*
* @return array
* (reference) of action links
*/
public static function &links() {
if (!(self::$_links)) {
$disableExtra = ts('Are you sure you want to disable this relationship?');
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit Contact Information'),
'url' => 'civicrm/contact/relatedcontact',
'qs' => 'action=update&reset=1&cid=%%cbid%%&rcid=%%cid%%',
'title' => ts('Edit Relationship'),
),
CRM_Core_Action::VIEW => array(
'name' => ts('Dashboard'),
'url' => 'civicrm/user',
'class' => 'no-popup',
'qs' => 'reset=1&id=%%cbid%%',
'title' => ts('View Relationship'),
),
);
if (CRM_Core_Permission::check('access CiviCRM')) {
self::$_links = array_merge(self::$_links, array(
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'url' => 'civicrm/contact/view/rel',
'qs' => 'action=disable&reset=1&cid=%%cid%%&id=%%id%%&rtype=%%rtype%%&selectedChild=rel&context=dashboard',
'extra' => 'onclick = "return confirm(\'' . $disableExtra . '\');"',
'title' => ts('Disable Relationship'),
),
));
}
}
// call the hook so we can modify it
CRM_Utils_Hook::links('view.contact.userDashBoard',
'Contact',
CRM_Core_DAO::$_nullObject,
self::$_links
);
return self::$_links;
}
}

View file

@ -0,0 +1,139 @@
<?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
*/
class CRM_Contact_Page_View_UserDashBoard_GroupContact extends CRM_Contact_Page_View_UserDashBoard {
/**
* Called when action is browse.
*/
public function browse() {
$count = CRM_Contact_BAO_GroupContact::getContactGroup(
$this->_contactId,
NULL,
NULL, TRUE, TRUE,
$this->_onlyPublicGroups,
NULL, NULL, TRUE
);
$in = CRM_Contact_BAO_GroupContact::getContactGroup(
$this->_contactId,
'Added',
NULL, FALSE, TRUE,
$this->_onlyPublicGroups,
NULL, NULL, TRUE
);
$pending = CRM_Contact_BAO_GroupContact::getContactGroup(
$this->_contactId,
'Pending',
NULL, FALSE, TRUE,
$this->_onlyPublicGroups,
NULL, NULL, TRUE
);
$out = CRM_Contact_BAO_GroupContact::getContactGroup(
$this->_contactId,
'Removed',
NULL, FALSE, TRUE,
$this->_onlyPublicGroups,
NULL, NULL, TRUE
);
$this->assign('groupCount', $count);
$this->assign_by_ref('groupIn', $in);
$this->assign_by_ref('groupPending', $pending);
$this->assign_by_ref('groupOut', $out);
}
/**
* called when action is update.
*
* @param int $groupId
*
* @return null
*/
public function edit($groupId = NULL) {
$this->assign('edit', $this->_edit);
if (!$this->_edit) {
return NULL;
}
$action = CRM_Utils_Request::retrieve('action', 'String',
CRM_Core_DAO::$_nullObject,
FALSE, 'browse'
);
if ($action == CRM_Core_Action::DELETE) {
$groupContactId = CRM_Utils_Request::retrieve('gcid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
$status = CRM_Utils_Request::retrieve('st', 'String', CRM_Core_DAO::$_nullObject, TRUE);
if (is_numeric($groupContactId) && $status) {
CRM_Contact_Page_View_GroupContact::del($groupContactId, $status, $this->_contactId);
}
$url = CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}");
CRM_Utils_System::redirect($url);
}
$controller = new CRM_Core_Controller_Simple(
'CRM_Contact_Form_GroupContact',
ts("Contact's Groups"),
CRM_Core_Action::ADD,
FALSE, FALSE, TRUE, FALSE
);
$controller->setEmbedded(TRUE);
$session = CRM_Core_Session::singleton();
$session->pushUserContext(
CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}"),
FALSE
);
$controller->reset();
$controller->set('contactId', $this->_contactId);
$controller->set('groupId', $groupId);
$controller->set('context', 'user');
$controller->set('onlyPublicGroups', $this->_onlyPublicGroups);
$controller->process();
$controller->run();
}
/**
* The main function that is called when the page loads.
*
* It decides the which action has to be taken for the page.
*/
public function run() {
$this->edit();
$this->browse();
}
}

View file

@ -0,0 +1,56 @@
<?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
*/
/**
* Dummy page for details of Email.
*/
class CRM_Contact_Page_View_Useradd extends CRM_Core_Page {
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run() {
$controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_Task_Useradd',
ts('Add User'),
CRM_Core_Action::ADD
);
$controller->setEmbedded(TRUE);
$controller->process();
$controller->run();
return parent::run();
}
}

View file

@ -0,0 +1,171 @@
<?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
*/
require_once 'Contact/Vcard/Build.php';
/**
* vCard export class.
*/
class CRM_Contact_Page_View_Vcard extends CRM_Contact_Page_View {
/**
* Heart of the vCard data assignment process.
*
* The runner gets all the metadata for the contact and calls the writeVcard method to output the vCard
* to the user.
*/
public function run() {
$this->preProcess();
$params = array();
$defaults = array();
$ids = array();
$params['id'] = $params['contact_id'] = $this->_contactId;
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, $ids);
// now that we have the contact's data - let's build the vCard
// TODO: non-US-ASCII support (requires changes to the Contact_Vcard_Build class)
$vcardNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'vcard_name'));
$vcard = new Contact_Vcard_Build('2.1');
if ($defaults['contact_type'] == 'Individual') {
$vcard->setName(CRM_Utils_Array::value('last_name', $defaults),
CRM_Utils_Array::value('first_name', $defaults),
CRM_Utils_Array::value('middle_name', $defaults),
CRM_Utils_Array::value('prefix', $defaults),
CRM_Utils_Array::value('suffix', $defaults)
);
$organizationName = CRM_Utils_Array::value('organization_name', $defaults);
if ($organizationName !== NULL) {
$vcard->addOrganization($organizationName);
}
}
elseif ($defaults['contact_type'] == 'Organization') {
$vcard->setName($defaults['organization_name'], '', '', '', '');
}
elseif ($defaults['contact_type'] == 'Household') {
$vcard->setName($defaults['household_name'], '', '', '', '');
}
$vcard->setFormattedName($defaults['display_name']);
$vcard->setSortString($defaults['sort_name']);
if (!empty($defaults['nick_name'])) {
$vcard->addNickname($defaults['nick_name']);
}
if (!empty($defaults['job_title'])) {
$vcard->setTitle($defaults['job_title']);
}
if (!empty($defaults['birth_date'])) {
$vcard->setBirthday(CRM_Utils_Array::value('birth_date', $defaults));
}
if (!empty($defaults['home_URL'])) {
$vcard->setURL($defaults['home_URL']);
}
// TODO: $vcard->setGeo($lat, $lon);
if (!empty($defaults['address'])) {
$stateProvices = CRM_Core_PseudoConstant::stateProvince();
$countries = CRM_Core_PseudoConstant::country();
foreach ($defaults['address'] as $location) {
// we don't keep PO boxes in separate fields
$pob = '';
$extend = CRM_Utils_Array::value('supplemental_address_1', $location);
if (!empty($location['supplemental_address_2'])) {
$extend .= ', ' . $location['supplemental_address_2'];
}
if (!empty($location['supplemental_address_3'])) {
$extend .= ', ' . $location['supplemental_address_3'];
}
$street = CRM_Utils_Array::value('street_address', $location);
$locality = CRM_Utils_Array::value('city', $location);
$region = NULL;
if (!empty($location['state_province_id'])) {
$region = $stateProvices[CRM_Utils_Array::value('state_province_id', $location)];
}
$country = NULL;
if (!empty($location['country_id'])) {
$country = $countries[CRM_Utils_Array::value('country_id', $location)];
}
$postcode = CRM_Utils_Array::value('postal_code', $location);
if (!empty($location['postal_code_suffix'])) {
$postcode .= '-' . $location['postal_code_suffix'];
}
$vcard->addAddress($pob, $extend, $street, $locality, $region, $postcode, $country);
$vcardName = $vcardNames[$location['location_type_id']];
if ($vcardName) {
$vcard->addParam('TYPE', $vcardName);
}
if (!empty($location['is_primary'])) {
$vcard->addParam('TYPE', 'PREF');
}
}
}
if (!empty($defaults['phone'])) {
foreach ($defaults['phone'] as $phone) {
$vcard->addTelephone($phone['phone']);
$vcardName = $vcardNames[$phone['location_type_id']];
if ($vcardName) {
$vcard->addParam('TYPE', $vcardName);
}
if ($phone['is_primary']) {
$vcard->addParam('TYPE', 'PREF');
}
}
}
if (!empty($defaults['email'])) {
foreach ($defaults['email'] as $email) {
$vcard->addEmail($email['email']);
$vcardName = $vcardNames[$email['location_type_id']];
if ($vcardName) {
$vcard->addParam('TYPE', $vcardName);
}
if ($email['is_primary']) {
$vcard->addParam('TYPE', 'PREF');
}
}
}
// all that's left is sending the vCard to the browser
$filename = CRM_Utils_String::munge($defaults['display_name']);
$vcard->send($filename . '.vcf', 'attachment', 'utf-8');
CRM_Utils_System::civiExit();
}
}