function browse() { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); $campaigns = CRM_Campaign_BAO_Campaign::getCampaignSummary(); if (!empty($campaigns)) { $campaignType = CRM_Core_PseudoConstant::campaignType(); $campaignStatus = CRM_Core_PseudoConstant::campaignStatus(); foreach ($campaigns as $cmpid => $campaign) { $campaigns[$cmpid]['campaign_id'] = $campaign['id']; $campaigns[$cmpid]['title'] = $campaign['title']; $campaigns[$cmpid]['name'] = $campaign['name']; $campaigns[$cmpid]['description'] = $campaign['description']; $campaigns[$cmpid]['campaign_type_id'] = $campaignType[$campaign['campaign_type_id']]; $campaigns[$cmpid]['status_id'] = $campaignStatus[$campaign['status_id']]; $action = array_sum(array_keys($this->actionLinks())); if ($campaign['is_active']) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $campaigns[$cmpid]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $campaign['id']), ts('more'), FALSE, 'campaign.selector.row', 'Campaign', $campaign['id']); } } $this->assign('campaigns', $campaigns); $this->assign('addCampaignUrl', CRM_Utils_System::url('civicrm/campaign/add', 'reset=1&action=add')); }
/** * Set variables up before form is built. * * @return void */ public function preProcess() { parent::preProcess(); $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0); $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID))); $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id); if ($reminderList && is_array($reminderList)) { // Add action links to each of the reminders foreach ($reminderList as &$format) { $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE; if ($format['is_active']) { $action += CRM_Core_Action::DISABLE; } else { $action += CRM_Core_Action::ENABLE; } $scheduleReminder = new CRM_Admin_Page_ScheduleReminders(); $links = $scheduleReminder->links(); $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}"; $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}"; $format['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $format['id']), ts('more'), FALSE, 'actionSchedule.manage.action', 'ActionSchedule', $this->_id); } } $this->assign('rows', $reminderList); $this->assign('setTab', $setTab); $this->assign('component', 'event'); // Update tab "disabled" css class $this->ajaxResponse['tabValid'] = is_array($reminderList) && count($reminderList) > 0; $this->setPageTitle(ts('Scheduled Reminder')); }
function browse() { require_once 'CRM/Core/Permission.php'; $campaigns = CRM_Campaign_BAO_Campaign::getCampaign(true); if (!empty($campaigns)) { require_once 'CRM/Campaign/BAO/Campaign.php'; $campaignType = CRM_Core_PseudoConstant::campaignType(); $campaignStatus = CRM_Core_PseudoConstant::campaignStatus(); foreach ($campaigns as $cmpid => $campaign) { $campaigns[$cmpid]['campaign_id'] = $campaign['id']; $campaigns[$cmpid]['title'] = $campaign['title']; $campaigns[$cmpid]['name'] = $campaign['name']; $campaigns[$cmpid]['description'] = $campaign['description']; $campaigns[$cmpid]['campaign_type_id'] = $campaignType[$campaign['campaign_type_id']]; $campaigns[$cmpid]['status_id'] = $campaignStatus[$campaign['status_id']]; $action = array_sum(array_keys($this->actionLinks())); if ($campaign['is_active']) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $campaigns[$cmpid]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $campaign['id'])); } } $this->assign('campaigns', $campaigns); $this->assign('addCampaignUrl', CRM_Utils_System::url('civicrm/campaign/add', 'reset=1&action=add')); }
/** * Basic page run function. */ public function run() { // Get link options for managing events. $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart'); $tabs = CRM_Event_Page_ManageEvent::tabs($enableCart); foreach ($tabs as $tab => $tabInfo) { $tabs[$tab]['name'] = $tabInfo['title']; $tabs[$tab]['qs'] = $tab == 'reminder' ? 'reset=1&action=browse&setTab=1&id=%%id%%' : 'reset=1&action=update&id=%%id%%'; } // Get link options for participant listings. $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0'); $participantLinks = array(); if (1 || !empty($statusTypes)) { $participantLinks[2] = array('name' => implode(', ', array_values($statusTypes)), 'url' => 'civicrm/event/search', 'qs' => 'reset=1&force=1&status=true&event=%%id%%', 'title' => ts('Counted', array('domain' => 'com.aghstrategies.eventpermissions'))); } if (!empty($statusTypesPending)) { $participantLinks[3] = array('name' => implode(', ', array_values($statusTypesPending)), 'url' => 'civicrm/event/search', 'qs' => 'reset=1&force=1&status=false&event=%%id%%', 'title' => ts('Not Counted', array('domain' => 'com.aghstrategies.eventpermissions'))); } $participantLinks[4] = array('name' => ts('Public Participant Listing', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/participant', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Public Participant Listing', array('domain' => 'com.aghstrategies.eventpermissions'))); // Get link options for event links. $eventLinks = array(array('name' => ts('Register Participant', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/participant/add', 'qs' => 'reset=1&action=add&context=standalone&eid=%%id%%', 'title' => ts('Register Participant', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Event Info', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/info', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Event Info', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Online Registration (Test-drive)', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/register', 'qs' => 'reset=1&action=preview&id=%%id%%', 'title' => ts('Online Registration (Test-drive)', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Online Registration (Live)', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/register', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Online Registration (Live)', array('domain' => 'com.aghstrategies.eventpermissions')))); $utils = new CRM_Eventpermissions_Utils(); $events = array(); foreach ($utils->myUpcomingEvents() as $id => $event) { $events[] = array('title' => CRM_Utils_System::href($event['title'], 'civicrm/event/info', "id={$id}&reset=1"), 'links' => CRM_Core_Action::formLink($tabs, NULL, array('id' => $id), ts('Configure', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.configure', 'Event', $id), 'participantLinks' => CRM_Core_Action::formLink($participantLinks, $event['participant_listing_id'] ? 6 : 3, array('id' => $id), ts('Participants', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.participants', 'Event', $id), 'eventLinks' => CRM_Core_Action::formLink($eventLinks, NULL, array('id' => $id), ts('Event Links', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.links', 'Event', $id)); } $this->assign('events', $events); parent::run(); }
function browse() { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); $statusTypes = array(); $dao = new CRM_Event_DAO_ParticipantStatusType(); $dao->orderBy('weight'); $dao->find(); $visibilities = CRM_Core_PseudoConstant::visibility(); // these statuses are reserved, but disabled by default - so should be disablable after being enabled $disablable = array('On waitlist', 'Awaiting approval', 'Pending from waitlist', 'Pending from approval', 'Rejected'); while ($dao->fetch()) { CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]); $action = array_sum(array_keys($this->links())); if ($dao->is_reserved) { $action -= CRM_Core_Action::DELETE; if (!in_array($dao->name, $disablable)) { $action -= CRM_Core_Action::DISABLE; } } $action -= $dao->is_active ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'participantStatusType.manage.action', 'ParticipantStatusType', $dao->id); $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id]; } $this->assign('rows', $statusTypes); }
/** * Browse all jobs. * * @param null $action * * @return void */ public function browse($action = NULL) { $qm = new CRM_Queryrunner_QueryManager(); // using Export action for Execute. Doh. if ($this->_action & CRM_Core_Action::EXPORT) { $qm->execute($this->_id, TRUE); $name = $qm->getNameFromId($this->_id); CRM_Core_Session::setStatus(ts("The {$name} query has been executed."), ts("Executed"), "success"); } $freqs = CRM_Queryrunner_Query::getQueryFrequency(); $rows = array(); foreach ($qm->queries as $query) { $action = array_sum(array_keys($this->links())); if ($query->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $query->action = CRM_Core_Action::formLink(self::links(), $action, array('id' => $query->id), ts('more'), FALSE, 'query.manage.action', 'Query', $query->id); $query->last_run = $query->last_run ? date('M j, Y, g:ia', $query->last_run) : 'never'; $query->scheduled_run = $query->scheduled_run ? date('M j, Y, g:ia', $query->scheduled_run) : ''; $query->run_frequency = $freqs[$query->run_frequency]; $query = get_object_vars($query); $rows[] = $query; if ($query['id'] == $this->_id) { $this->assign('query', $query); } } $this->assign('rows', $rows); if ($this->_action & CRM_Core_Action::PREVIEW) { $this->assign('server', isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '')); $this->assign('doc_root', $_SERVER['DOCUMENT_ROOT']); } }
function browse() { require_once 'CRM/Core/Permission.php'; $surveys = CRM_Campaign_BAO_Survey::getSurvey(true); if (!empty($surveys)) { require_once 'CRM/Campaign/BAO/Campaign.php'; $surveyType = CRM_Campaign_BAO_Survey::getSurveyActivityType(); $campaigns = CRM_Campaign_BAO_Campaign::getAllCampaign(); $activityTypes = CRM_Core_OptionGroup::values('activity_type', false, false, false, false, 'name'); foreach ($surveys as $sid => $survey) { $surveys[$sid]['campaign_id'] = $campaigns[$survey['campaign_id']]; $surveys[$sid]['activity_type_id'] = $surveyType[$survey['activity_type_id']]; $surveys[$sid]['release_frequency'] = $survey['release_frequency_interval'] . ' ' . $survey['release_frequency_unit']; $action = array_sum(array_keys($this->actionLinks())); if ($survey['is_active']) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $surveys[$sid]['action'] = CRM_Core_Action::formLink($this->actionLinks(), $action, array('id' => $sid)); } } $this->assign('surveys', $surveys); $this->assign('addSurveyUrl', CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add')); }
/** * Function to set variables up before form is built * * @return void * @access public */ function preProcess() { parent::preProcess(); $newReminder = CRM_Utils_Request::retrieve('new', 'Boolean', $this, FALSE, FALSE); if ($this->_action & CRM_Core_Action::UPDATE && !$newReminder) { $field = 'civicrm_event'; if ($this->_isTemplate) { $field = 'event_template'; } $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $field, $this->_id); if ($reminderList && is_array($reminderList)) { // Add action links to each of the reminders foreach ($reminderList as &$format) { $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE; if ($format['is_active']) { $action += CRM_Core_Action::DISABLE; } else { $action += CRM_Core_Action::ENABLE; } $links = CRM_Admin_Page_ScheduleReminders::links(); $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&eventId={$this->_id}"; $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&eventId={$this->_id}"; $format['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $format['id']), ts('more'), FALSE, 'event.reminder.list', 'Event', $this->_id); } } else { $reminderList = TRUE; } $this->assign('rows', $reminderList); // Update tab "disabled" css class $this->ajaxResponse['tabValid'] = !empty($reminderList) && is_array($reminderList); } }
function run() { // get the requested action $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); // assign vars to templates $this->assign('action', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); if ($action & CRM_Core_Action::UPDATE) { $controller = new CRM_Core_Controller_Simple('CRM_Wci_Form_ProgressBar', 'Edit Progressbar', CRM_Core_Action::UPDATE); $controller->set('id', $id); $controller->process(); return $controller->run(); } elseif ($action & CRM_Core_Action::COPY) { try { $sql = "INSERT INTO civicrm_wci_progress_bar (name, starting_amount, goal_amount)\n SELECT concat(name, '-', (SELECT MAX(id) FROM civicrm_wci_progress_bar)),\n starting_amount, goal_amount FROM civicrm_wci_progress_bar\n WHERE id=%1"; CRM_Core_DAO::executeQuery($sql, array(1 => array($id, 'Integer'))); $new_pb_id = CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()'); $sql = "INSERT INTO civicrm_wci_progress_bar_formula\n (contribution_page_id, financial_type_id, progress_bar_id, start_date, end_date, percentage)\n SELECT contribution_page_id, financial_type_id, %1, start_date,\n end_date, percentage FROM civicrm_wci_progress_bar_formula WHERE progress_bar_id=%2"; CRM_Core_DAO::executeQuery($sql, array(1 => array($new_pb_id, 'Integer'), 2 => array($id, 'Integer'))); } catch (Exception $e) { CRM_Core_Session::setStatus(ts('Failed to create Progress bar. ') . $e->getMessage(), '', 'error'); $transaction->rollback(); } } elseif ($action & CRM_Core_Action::DELETE) { $errorScope = CRM_Core_TemporaryErrorScope::useException(); try { $transaction = new CRM_Core_Transaction(); $sql = "DELETE FROM civicrm_wci_progress_bar_formula where progress_bar_id = %1"; $params = array(1 => array($id, 'Integer')); CRM_Core_DAO::executeQuery($sql, $params); $sql = "DELETE FROM civicrm_wci_progress_bar where id = %1"; $params = array(1 => array($id, 'Integer')); CRM_Core_DAO::executeQuery($sql, $params); $transaction->commit(); } catch (Exception $e) { $errmgs = $e->getMessage() . ts('. Check whether progressbar is used by any widget or not'); CRM_Core_Session::setStatus($errmgs, '', 'error'); $transaction->rollback(); } } // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml CRM_Utils_System::setTitle(ts('Progress Bar List')); $query = "SELECT * FROM civicrm_wci_progress_bar"; $params = array(); $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_ProgressBar'); while ($dao->fetch()) { $con_page[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $con_page[$dao->id]); $action = array_sum(array_keys($this->actionLinks())); //build the normal action links. $con_page[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id)); } if (isset($con_page)) { $this->assign('rows', $con_page); } return parent::run(); }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $links =& CRM_Contact_Page_View_Relationship::links(); $mask = CRM_Core_Action::mask($this->_permission); $currentRelationships = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, CRM_CONTACT_BAO_RELATIONSHIP_CURRENT, 0, 0, 0, $links, $mask); $pastRelationships = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, CRM_CONTACT_BAO_RELATIONSHIP_PAST, 0, 0, 0, $links, $mask); $disableRelationships = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, CRM_CONTACT_BAO_RELATIONSHIP_DISABLED, 0, 0, 0, $links, $mask); $this->assign('currentRelationships', $currentRelationships); $this->assign('pastRelationships', $pastRelationships); $this->assign('disableRelationships', $disableRelationships); }
function run() { // get the requested action $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); // assign vars to templates $this->assign('action', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); if ($action & CRM_Core_Action::UPDATE) { $controller = new CRM_Core_Controller_Simple('CRM_Wci_Form_CreateWidget', 'Edit Widget', CRM_Core_Action::UPDATE); $controller->set('id', $id); $controller->process(); return $controller->run(); } elseif ($action & CRM_Core_Action::COPY) { try { $sql = "INSERT INTO civicrm_wci_widget (title, logo_image, image,\n button_title, button_link_to, progress_bar_id, description,\n email_signup_group_id, size_variant, color_title, color_title_bg,\n color_progress_bar, color_progress_bar_bg, color_widget_bg, color_description, color_border,\n color_button, color_button_bg, hide_title, hide_border, hide_pbcap,\n color_btn_newsletter, color_btn_newsletter_bg, newsletter_text,\n color_newsletter_text, style_rules, override, custom_template, show_pb_perc)\n SELECT concat(title, '-', (SELECT MAX(id) FROM civicrm_wci_widget)), logo_image, image,\n button_title, button_link_to, progress_bar_id, description,\n email_signup_group_id, size_variant, color_title, color_title_bg,\n color_progress_bar, color_progress_bar_bg, color_widget_bg, color_description, color_border,\n color_button, color_button_bg, hide_title, hide_border, hide_pbcap,\n color_btn_newsletter, color_btn_newsletter_bg, newsletter_text,\n color_newsletter_text, style_rules, override, custom_template, show_pb_perc FROM civicrm_wci_widget WHERE id=%1"; CRM_Core_DAO::executeQuery("SET foreign_key_checks = 0;"); CRM_Core_DAO::executeQuery($sql, array(1 => array($id, 'Integer'))); CRM_Core_DAO::executeQuery("SET foreign_key_checks = 1;"); } catch (Exception $e) { CRM_Core_Session::setStatus(ts('Failed to create widget. ') . $e->getMessage(), '', 'error'); $transaction->rollback(); } } elseif ($action & CRM_Core_Action::DELETE) { try { $transaction = new CRM_Core_Transaction(); $sql = "DELETE FROM civicrm_wci_widget where id = %1"; $params = array(1 => array($id, 'Integer')); CRM_Core_DAO::executeQuery($sql, $params); $transaction->commit(); } catch (Exception $e) { CRM_Core_Session::setStatus(ts('Failed to delete widget. ') . $e->getMessage(), '', 'error'); $transaction->rollback(); } } CRM_Utils_System::setTitle(ts('Widget List')); $query = "SELECT * FROM civicrm_wci_widget"; $params = array(); $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget'); while ($dao->fetch()) { $wid_page[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $wid_page[$dao->id]); $wid_page[$dao->id]['title'] = $wid_page[$dao->id]['title']; $description = $wid_page[$dao->id]['description']; $wid_page[$dao->id]['description'] = strip_tags($description); $action = array_sum(array_keys($this->actionLinks())); //build the normal action links. $wid_page[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id)); } if (isset($wid_page)) { $this->assign('rows', $wid_page); } parent::run(); }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $note =& new CRM_Core_DAO_Note(); $note->entity_table = 'civicrm_contact'; $note->entity_id = $this->_contactId; $note->orderBy('modified_date desc'); $values = array(); $links =& CRM_Profile_Page_Note::links(); $action = array_sum(CRM_Profile_Page_Note::links()); $note->find(); while ($note->fetch()) { $values[$note->id] = array(); 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)); } $this->assign('notes', $values); }
function run() { // get the requested action $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); // assign vars to templates $this->assign('action', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); if ($action & CRM_Core_Action::UPDATE) { $controller = new CRM_Core_Controller_Simple('CRM_Wci_Form_NewEmbedCode', 'Edit Embed Code', CRM_Core_Action::UPDATE); $controller->set('id', $id); $controller->process(); return $controller->run(); } elseif ($action & CRM_Core_Action::DELETE) { try { $transaction = new CRM_Core_Transaction(); $sql = "DELETE FROM civicrm_wci_embed_code where id = %1"; $params = array(1 => array($id, 'Integer')); CRM_Core_DAO::executeQuery($sql, $params); $transaction->commit(); } catch (Exception $e) { CRM_Core_Session::setStatus(ts('Failed to delete embed code. ') . $e->getMessage(), '', 'error'); $transaction->rollback(); } } CRM_Utils_System::setTitle(ts('Embed Code List')); $query = "SELECT * FROM civicrm_wci_embed_code"; $params = array(); $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_EmbedCode'); while ($dao->fetch()) { $emb_code[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $emb_code[$dao->id]); $emb_code[$dao->id]['id'] = $emb_code[$dao->id]['id']; $emb_code[$dao->id]['name'] = $emb_code[$dao->id]['name']; $action = array_sum(array_keys($this->actionLinks())); //build the normal action links. $emb_code[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id)); } if (isset($emb_code)) { $this->assign('rows', $emb_code); } parent::run(); }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $note =& new CRM_Core_DAO_Note(); $note->entity_table = 'civicrm_contact'; $note->entity_id = $this->_contactId; $note->orderBy('modified_date desc'); $values = array(); $links =& CRM_Contact_Page_View_Note::links(); $action = array_sum(array_keys($links)) & CRM_Core_Action::mask($this->_permission); $note->find(); while ($note->fetch()) { $values[$note->id] = array(); 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)); $contact = new CRM_Contact_DAO_Contact(); $contact->id = $note->contact_id; $contact->find(); $contact->fetch(); $values[$note->id]['createdBy'] = $contact->display_name; } $this->assign('notes', $values); }
public function browse() { $surveys = CRM_Campaign_BAO_Survey::getSurveySummary(); if (!empty($surveys)) { $surveyType = CRM_Campaign_BAO_Survey::getSurveyActivityType(); $campaigns = CRM_Campaign_BAO_Campaign::getAllCampaign(); $activityTypes = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, FALSE, 'name'); foreach ($surveys as $sid => $survey) { $surveys[$sid]['campaign_id'] = $campaigns[$survey['campaign_id']]; $surveys[$sid]['activity_type_id'] = $surveyType[$survey['activity_type_id']]; $surveys[$sid]['release_frequency'] = $survey['release_frequency_interval'] . ' ' . $survey['release_frequency_unit']; $action = array_sum(array_keys($this->actionLinks())); if ($survey['is_active']) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $surveys[$sid]['action'] = CRM_Core_Action::formLink($this->actionLinks(), $action, array('id' => $sid), ts('more'), FALSE, 'survey.selector.row', 'Survey', $sid); } } $this->assign('surveys', $surveys); $this->assign('addSurveyUrl', CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add')); }
/** * Function to set variables up before form is built * * @return void * @access public */ function preProcess() { parent::preProcess(); $newReminder = CRM_Utils_Request::retrieve('new', 'Boolean', $this, FALSE, FALSE); if ($this->_action & CRM_Core_Action::UPDATE && !$newReminder) { $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, 'civicrm_event', $this->_id); if (is_array($reminderList)) { // Add action links to each of the reminders foreach ($reminderList as &$format) { $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE; if ($format['is_active']) { $action += CRM_Core_Action::DISABLE; } else { $action += CRM_Core_Action::ENABLE; } $links = CRM_Admin_Page_ScheduleReminders::links(); $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&eventId={$this->_id}"; $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&eventId={$this->_id}"; $format['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $format['id'])); } $this->assign('rows', $reminderList); } } }
/** * returns all the rows in the given offset and rowCount * * @param enum $action the action being performed * @param int $offset the row number to start from * @param int $rowCount the number of rows to return * @param string $sort the sql string that describes the sort order * @param enum $output what should the result set include (web/email/csv) * * @return int the total number of rows for this action */ function &getRows($action, $offset, $rowCount, $sort, $output = null) { $config =& CRM_Core_Config::singleton(); if (($output == CRM_CORE_SELECTOR_CONTROLLER_EXPORT || $output == CRM_CORE_SELECTOR_CONTROLLER_SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') { $includeContactIds = true; } else { $includeContactIds = false; } // note the formvalues were given by CRM_Contact_Form_Search to us // and contain the search criteria (parameters) // note that the default action is basic $result = $this->_query->searchQuery($offset, $rowCount, $sort, false, $includeContactIds); // process the result of the query $rows = array(); $mask = CRM_Core_Action::mask(CRM_Core_Permission::getPermission()); $mapMask = $mask & 4095; // mask value to hide map link if there are not lat/long $gc = CRM_Core_SelectValues::groupContactStatus(); /* Dirty session hack to get at the context */ $session =& CRM_Core_Session::singleton(); $context = $session->get('context', 'CRM_Contact_Controller_Search'); // CRM_Core_Error::debug( 'p', self::$_properties ); while ($result->fetch()) { $row = array(); // the columns we are interested in foreach ($GLOBALS['_CRM_CONTACT_SELECTOR']['_properties'] as $property) { if ($property == 'status') { continue; } $row[$property] = $result->{$property}; } if (!empty($result->postal_code_suffix)) { $row['postal_code'] .= "-" . $result->postal_code_suffix; } if ($output != CRM_CORE_SELECTOR_CONTROLLER_EXPORT || $context == 'smog') { if (empty($result->status)) { $row['status'] = ts('Smart'); } else { $row['status'] = $gc[$result->status]; } } if ($output != CRM_CORE_SELECTOR_CONTROLLER_EXPORT && $output != CRM_CORE_SELECTOR_CONTROLLER_SCREEN) { $row['checkbox'] = CRM_CORE_FORM_CB_PREFIX . $result->contact_id; if (is_numeric(CRM_Utils_Array::value('geo_code_1', $row))) { $row['action'] = CRM_Core_Action::formLink(CRM_Contact_Selector::links(), $mask, array('id' => $result->contact_id)); } else { $row['action'] = CRM_Core_Action::formLink(CRM_Contact_Selector::links(), $mapMask, array('id' => $result->contact_id)); } $contact_type = '<img src="' . $config->resourceBase . 'i/contact_'; switch ($result->contact_type) { case 'Individual': $contact_type .= 'ind.gif" alt="' . ts('Individual') . '" />'; break; case 'Household': $contact_type .= 'house.png" alt="' . ts('Household') . '" height="16" width="16" />'; break; case 'Organization': $contact_type .= 'org.gif" alt="' . ts('Organization') . '" height="16" width="18" />'; break; } $row['contact_type'] = $contact_type; } $rows[] = $row; } return $rows; }
/** * Build the form object. */ public function buildQuickForm() { //load form for child blocks if ($this->_addBlockName) { $className = 'CRM_Contact_Form_Edit_' . $this->_addBlockName; return $className::buildQuickForm($this); } if ($this->_action == CRM_Core_Action::UPDATE) { $deleteExtra = json_encode(ts('Are you sure you want to delete contact image.')); $deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Contact Image'), 'url' => 'civicrm/contact/image', 'qs' => 'reset=1&cid=%%id%%&action=delete', 'extra' => 'onclick = "' . htmlspecialchars("if (confirm({$deleteExtra})) this.href+='&confirmed=1'; else return false;") . '"')); $deleteURL = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $this->_contactId), ts('more'), FALSE, 'contact.image.delete', 'Contact', $this->_contactId); $this->assign('deleteURL', $deleteURL); } //build contact type specific fields $className = 'CRM_Contact_Form_Edit_' . $this->_contactType; $className::buildQuickForm($this); // build Custom data if Custom data present in edit option $buildCustomData = 'noCustomDataPresent'; if (array_key_exists('CustomData', $this->_editOptions)) { $buildCustomData = "customDataPresent"; } // subtype is a common field. lets keep it here $subtypes = CRM_Contact_BAO_Contact::buildOptions('contact_sub_type', 'create', array('contact_type' => $this->_contactType)); if (!empty($subtypes)) { $this->addField('contact_sub_type', array('label' => ts('Contact Type'), 'options' => $subtypes, 'class' => $buildCustomData, 'multiple' => 'multiple', 'options-url' => FALSE)); } // build edit blocks ( custom data, demographics, communication preference, notes, tags and groups ) foreach ($this->_editOptions as $name => $label) { if ($name == 'Address') { $this->_blocks['Address'] = $this->_editOptions['Address']; continue; } if ($name == 'TagsAndGroups') { continue; } $className = 'CRM_Contact_Form_Edit_' . $name; $className::buildQuickForm($this); } // build tags and groups CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($this, 0, CRM_Contact_Form_Edit_TagsAndGroups::ALL, FALSE, NULL, 'Group(s)', 'Tag(s)', NULL, 'select'); // build location blocks. CRM_Contact_Form_Edit_Lock::buildQuickForm($this); CRM_Contact_Form_Location::buildQuickForm($this); // add attachment $this->addField('image_URL', array('maxlength' => '60', 'label' => ts('Browse/Upload Image'))); // add the dedupe button $this->addElement('submit', $this->_dedupeButtonName, ts('Check for Matching Contact(s)')); $this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact')); $this->addElement('submit', $this->getButtonName('next', 'sharedHouseholdDuplicate'), ts('Save With Duplicate Household')); $buttons = array(array('type' => 'upload', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => TRUE)); if (CRM_Core_Permission::check('add contacts')) { $buttons[] = array('type' => 'upload', 'name' => ts('Save and New'), 'spacing' => ' ', 'subName' => 'new'); } $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel')); if (!empty($this->_values['contact_sub_type'])) { $this->_oldSubtypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($this->_values['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR)); } $this->assign('oldSubtypes', json_encode($this->_oldSubtypes)); $this->addButtons($buttons); }
/** * Browse all resources. * * @return void * @access public * @static */ function browse($action = NULL) { $units = CRM_Booking_DAO_ResourceConfigOption::buildOptions('unit_id', 'create'); // get all config option sorted by weight $configOptions = array(); $dao = new CRM_Booking_DAO_ResourceConfigOption(); $dao->set_id = $this->_sid; $dao->orderBy('weight'); $dao->is_deleted = FALSE; $dao->find(); while ($dao->fetch()) { $configOptions[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $configOptions[$dao->id]); $configOptions[$dao->id]['unit'] = CRM_Utils_Array::value(CRM_Utils_Array::value('unit_id', $configOptions[$dao->id]), $units); // form all action links $action = array_sum(array_keys($this->links())); // update enable/disable links. if ($dao->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $configOptions[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id, 'sid' => $this->_sid)); } $this->assign('rows', $configOptions); }
/** * Return PCP Block info for dashboard. * * @param int $contactId * * @return array * array of Pcp if found */ public static function getPcpDashboardInfo($contactId) { $links = self::pcpLinks(); $query = "\nSELECT * FROM civicrm_pcp pcp\nWHERE pcp.is_active = 1\n AND pcp.contact_id = %1\nORDER BY page_type, page_id"; $params = array(1 => array($contactId, 'Integer')); $pcpInfoDao = CRM_Core_DAO::executeQuery($query, $params); $pcpInfo = array(); $hide = $mask = array_sum(array_keys($links['all'])); $contactPCPPages = array(); $event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $contribute = CRM_Contribute_PseudoConstant::contributionPage(); $pcpStatus = CRM_Contribute_PseudoConstant::pcpStatus(); $approved = CRM_Utils_Array::key('Approved', $pcpStatus); while ($pcpInfoDao->fetch()) { $mask = $hide; if ($links) { $replace = array('pcpId' => $pcpInfoDao->id, 'pcpBlock' => $pcpInfoDao->pcp_block_id, 'pageComponent' => $pcpInfoDao->page_type); } $pcpLink = $links['all']; $class = ''; if ($pcpInfoDao->status_id != $approved || $pcpInfoDao->is_active != 1) { $class = 'disabled'; if (!$pcpInfoDao->tellfriend) { $mask -= CRM_Core_Action::DETACH; } } if ($pcpInfoDao->is_active == 1) { $mask -= CRM_Core_Action::ENABLE; } else { $mask -= CRM_Core_Action::DISABLE; } $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace, ts('more'), FALSE, 'pcp.dashboard.active', 'PCP', $pcpInfoDao->id); $component = $pcpInfoDao->page_type; $pageTitle = CRM_Utils_Array::value($pcpInfoDao->page_id, ${$component}); $pcpInfo[] = array('pageTitle' => $pageTitle, 'pcpId' => $pcpInfoDao->id, 'pcpTitle' => $pcpInfoDao->title, 'pcpStatus' => $pcpStatus[$pcpInfoDao->status_id], 'action' => $action, 'class' => $class); $contactPCPPages[$pcpInfoDao->page_type][] = $pcpInfoDao->page_id; } $excludePageClause = $clause = NULL; if (!empty($contactPCPPages)) { foreach ($contactPCPPages as $component => $entityIds) { $excludePageClause[] = "\n( target_entity_type = '{$component}'\nAND target_entity_id NOT IN ( " . implode(',', $entityIds) . ") )"; } $clause = ' AND ' . implode(' OR ', $excludePageClause); } $query = "\nSELECT *\nFROM civicrm_pcp_block block\nLEFT JOIN civicrm_pcp pcp ON pcp.pcp_block_id = block.id\nWHERE block.is_active = 1\n{$clause}\nGROUP BY block.id\nORDER BY target_entity_type, target_entity_id\n"; $pcpBlockDao = CRM_Core_DAO::executeQuery($query); $pcpBlock = array(); $mask = 0; while ($pcpBlockDao->fetch()) { if ($links) { $replace = array('pageId' => $pcpBlockDao->target_entity_id, 'pageComponent' => $pcpBlockDao->target_entity_type); } $pcpLink = $links['add']; $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace, ts('more'), FALSE, 'pcp.dashboard.other', "{$pcpBlockDao->target_entity_type}_PCP", $pcpBlockDao->target_entity_id); $component = $pcpBlockDao->target_entity_type; if ($pageTitle = CRM_Utils_Array::value($pcpBlockDao->target_entity_id, ${$component})) { $pcpBlock[] = array('pageId' => $pcpBlockDao->target_entity_id, 'pageTitle' => $pageTitle, 'action' => $action); } } return array($pcpBlock, $pcpInfo); }
/** * Browse all Providers. * * @param array $action */ public function browse($action = NULL) { $providers = CRM_SMS_BAO_Provider::getProviders(); $rows = array(); foreach ($providers as $provider) { $action = array_sum(array_keys($this->links())); // update enable/disable links. if ($provider['is_active']) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $apiTypes = CRM_Core_OptionGroup::values('sms_api_type', FALSE, FALSE, FALSE, NULL, 'label'); $provider['api_type'] = $apiTypes[$provider['api_type']]; $provider['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $provider['id']), ts('more'), FALSE, 'sms.provider.row', 'SMSProvider', $provider['id']); $rows[] = $provider; } $this->assign('rows', $rows); }
/** * Browse all membership types. * * * @return void * @access public * @static */ function browse() { // get all membership types sorted by weight $membershipType = array(); require_once 'CRM/Member/DAO/MembershipType.php'; $dao =& new CRM_Member_DAO_MembershipType(); $dao->orderBy('weight'); $dao->find(); require_once 'CRM/Utils/Money.php'; while ($dao->fetch()) { $membershipType[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $membershipType[$dao->id]); // fix the display of the monetary value, CRM-4038 if (CRM_Utils_Array::value('minimum_fee', $membershipType[$dao->id])) { $membershipType[$dao->id]['minimum_fee'] = CRM_Utils_Money::format($membershipType[$dao->id]['minimum_fee'], null, '%a'); } //adding column for relationship type label. CRM-4178. if ($dao->relationship_type_id) { $relationshipName = 'label_' . $dao->relationship_direction; $membershipType[$dao->id]['relationshipTypeName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $dao->relationship_type_id, $relationshipName); } // form all action links $action = array_sum(array_keys($this->links())); // update enable/disable links depending on if it is is_reserved or is_active if (!isset($dao->is_reserved)) { if ($dao->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $membershipType[$dao->id]['order'] = $membershipType[$dao->id]['weight']; $membershipType[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id)); } } $returnURL = CRM_Utils_System::url('civicrm/admin/member/membershipType', "reset=1&action=browse"); require_once 'CRM/Utils/Weight.php'; CRM_Utils_Weight::addOrder($membershipType, 'CRM_Member_DAO_MembershipType', 'id', $returnURL); CRM_Member_BAO_MembershipType::convertDayFormat($membershipType); $this->assign('rows', $membershipType); }
/** * Retrieve cases related to particular contact or whole contact * used in Dashboad and Tab * * @param boolean $allCases * * @param int $userID * * @param String $type /upcoming,recent,all/ * * @param string $context * * @return array Array of Cases * * @access public */ static function getCases($allCases = TRUE, $userID = NULL, $type = 'upcoming', $context = 'dashboard') { $condition = NULL; $casesList = array(); //validate access for own cases. if (!self::accessCiviCase()) { return $casesList; } if (!$userID) { $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); } //validate access for all cases. if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) { $allCases = FALSE; } $condition = " AND civicrm_case.is_deleted = 0 "; if (!$allCases) { $condition .= " AND case_relationship.contact_id_b = {$userID} "; } if ($type == 'upcoming' || $type == 'any') { $closedId = CRM_Core_OptionGroup::getValue('case_status', 'Closed', 'name'); $condition .= "\nAND civicrm_case.status_id != {$closedId}"; } $query = self::getCaseActivityQuery($type, $userID, $condition); $queryParams = array(); $result = CRM_Core_DAO::executeQuery($query, $queryParams); $caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND v.name = 'Urgent' "); $resultFields = array('contact_id', 'contact_type', 'sort_name', 'phone', 'case_id', 'case_subject', 'case_type', 'case_type_id', 'status_id', 'case_status', 'case_status_name', 'activity_type_id', 'case_start_date', 'case_role'); if ($type == 'upcoming') { $resultFields[] = 'case_scheduled_activity_date'; $resultFields[] = 'case_scheduled_activity_type_name'; $resultFields[] = 'case_scheduled_activity_type'; $resultFields[] = 'case_scheduled_activity_id'; } elseif ($type == 'recent') { $resultFields[] = 'case_recent_activity_date'; $resultFields[] = 'case_recent_activity_type_name'; $resultFields[] = 'case_recent_activity_type'; $resultFields[] = 'case_recent_activity_id'; } elseif ($type == 'any') { $resultFields[] = 'case_activity_date'; $resultFields[] = 'case_activity_type_name'; $resultFields[] = 'case_activity_type'; $resultFields[] = 'case_activity_id'; } // we're going to use the usual actions, so doesn't make sense to duplicate definitions $actions = CRM_Case_Selector_Search::links(); // check is the user has view/edit signer permission $permissions = array(CRM_Core_Permission::VIEW); if (CRM_Core_Permission::check('access all cases and activities') || !$allCases && CRM_Core_Permission::check('access my cases and activities')) { $permissions[] = CRM_Core_Permission::EDIT; } if (CRM_Core_Permission::check('delete in CiviCase')) { $permissions[] = CRM_Core_Permission::DELETE; } $mask = CRM_Core_Action::mask($permissions); while ($result->fetch()) { foreach ($resultFields as $donCare => $field) { $casesList[$result->case_id][$field] = $result->{$field}; if ($field == 'contact_type') { $casesList[$result->case_id]['contact_type_icon'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type); $casesList[$result->case_id]['action'] = CRM_Core_Action::formLink($actions['primaryActions'], $mask, array('id' => $result->case_id, 'cid' => $result->contact_id, 'cxt' => $context), ts('more'), FALSE, 'case.actions.primary', 'Case', $result->case_id); $casesList[$result->case_id]['moreActions'] = CRM_Core_Action::formLink($actions['moreActions'], $mask, array('id' => $result->case_id, 'cid' => $result->contact_id, 'cxt' => $context), ts('more'), TRUE, 'case.actions.more', 'Case', $result->case_id); } elseif ($field == 'case_status') { if (in_array($result->{$field}, $caseStatus)) { $casesList[$result->case_id]['class'] = "status-urgent"; } else { $casesList[$result->case_id]['class'] = "status-normal"; } } } //CRM-4510. $caseTypes = CRM_Case_PseudoConstant::caseType('name'); $caseManagerContact = self::getCaseManagerContact($caseTypes[$result->case_type_id], $result->case_id); if (!empty($caseManagerContact)) { $casesList[$result->case_id]['casemanager_id'] = CRM_Utils_Array::value('casemanager_id', $caseManagerContact); $casesList[$result->case_id]['casemanager'] = CRM_Utils_Array::value('casemanager', $caseManagerContact); } //do check user permissions for edit/view activity. if (($actId = CRM_Utils_Array::value('case_scheduled_activity_id', $casesList[$result->case_id])) || ($actId = CRM_Utils_Array::value('case_recent_activity_id', $casesList[$result->case_id]))) { $casesList[$result->case_id]["case_{$type}_activity_editable"] = self::checkPermission($actId, 'edit', $casesList[$result->case_id]['activity_type_id'], $userID); $casesList[$result->case_id]["case_{$type}_activity_viewable"] = self::checkPermission($actId, 'view', $casesList[$result->case_id]['activity_type_id'], $userID); } } return $casesList; }
/** * @param $rows */ function addActions(&$rows) { $config = CRM_Core_Config::singleton(); $permissions = array(CRM_Core_Permission::getPermission()); if (CRM_Core_Permission::check('delete contacts')) { $permissions[] = CRM_Core_Permission::DELETE; } $mask = CRM_Core_Action::mask($permissions); // mask value to hide map link if there are not lat/long $mapMask = $mask & 4095; // mask value to hide map link if there are not lat/long $mapMask = $mask & 4095; $links = self::links($this->_context, $this->_contextMenu, $this->_key); foreach ($rows as $id => &$row) { if (!empty($this->_formValues['deleted_contacts']) && CRM_Core_Permission::check('access deleted contacts')) { $links = array(array('name' => ts('View'), 'url' => 'civicrm/contact/view', 'qs' => 'reset=1&cid=%%id%%', 'class' => 'no-popup', 'title' => ts('View Contact Details')), array('name' => ts('Restore'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&restore=1', 'title' => ts('Restore Contact'))); if (CRM_Core_Permission::check('delete contacts')) { $links[] = array('name' => ts('Delete Permanently'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&skip_undelete=1', 'title' => ts('Permanently Delete Contact')); } $row['action'] = CRM_Core_Action::formLink($links, null, array('id' => $row['contact_id']), ts('more'), FALSE, 'contact.selector.actions', 'Contact', $row['contact_id']); } elseif (is_numeric(CRM_Utils_Array::value('geo_code_1', $row)) || $config->mapGeoCoding && !empty($row['city']) && CRM_Utils_Array::value('state_province', $row)) { $row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $row['contact_id']), ts('more'), FALSE, 'contact.selector.actions', 'Contact', $row['contact_id']); } else { $row['action'] = CRM_Core_Action::formLink($links, $mapMask, array('id' => $row['contact_id']), ts('more'), FALSE, 'contact.selector.actions', 'Contact', $row['contact_id']); } // allow components to add more actions CRM_Core_Component::searchAction($row, $row['contact_id']); if (!empty($row['contact_type_orig'])) { $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($row['contact_type_orig'], FALSE, $row['contact_id']); } } }
/** * Browse all Scheduled Reminders settings. * * @param null $action * * @return void */ public function browse($action = NULL) { // Get list of configured reminders $reminderList = CRM_Core_BAO_ActionSchedule::getList(); if (is_array($reminderList)) { // Add action links to each of the reminders foreach ($reminderList as &$format) { $action = array_sum(array_keys($this->links())); if ($format['is_active']) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $format['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $format['id']), ts('more'), FALSE, 'actionSchedule.manage.action', 'ActionSchedule', $format['id']); } } $this->assign('rows', $reminderList); }
/** * Browse all custom data groups. * * * @return void * @access public * @static */ function browse() { // get all custom groups sorted by weight $premiums = array(); require_once 'CRM/Contribute/DAO/Product.php'; $dao =& new CRM_Contribute_DAO_Product(); // set the domain_id parameter $config =& CRM_Core_Config::singleton(); $dao->orderBy('name'); $dao->find(); while ($dao->fetch()) { $premiums[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $premiums[$dao->id]); // form all action links $action = array_sum(array_keys($this->links())); if ($dao->is_active) { $action -= CRM_CORE_ACTION_ENABLE; } else { $action -= CRM_CORE_ACTION_DISABLE; } $premiums[$dao->id]['action'] = CRM_Core_Action::formLink(CRM_Contribute_Page_ManagePremiums::links(), $action, array('id' => $dao->id)); } $this->assign('rows', $premiums); }
function browse() { $rows = CRM_Contact_BAO_ContactType::contactTypeInfo(true); foreach ($rows as $key => $value) { $mask = null; if (CRM_Utils_Array::value('is_reserved', $value)) { $mask = CRM_Core_Action::UPDATE; } else { $mask -= CRM_Core_Action::DELETE - 2; if (CRM_Utils_Array::value('is_active', $value)) { $mask -= CRM_Core_Action::ENABLE; } else { $mask -= CRM_Core_Action::DISABLE; } } $rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $value['id'])); } $this->assign('rows', $rows); }
/** * Returns all the rows in the given offset and rowCount. * * @param string $action * The action being performed. * @param int $offset * The row number to start from. * @param int $rowCount * The number of rows to return. * @param string $sort * The sql string that describes the sort order. * @param string $output * What should the result set include (web/email/csv). * * @return array * rows in the given offset and rowCount */ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_activityClause); $rows = array(); $mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs(); $accessCiviMail = CRM_Core_Permission::check('access CiviMail'); //get all campaigns. $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); $engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel(); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); //get all activity types $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE); while ($result->fetch()) { $row = array(); // ignore rows where we dont have an activity id if (empty($result->activity_id)) { continue; } // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->{$property})) { $row[$property] = $result->{$property}; } } $contactId = CRM_Utils_Array::value('contact_id', $row); if (!$contactId) { $contactId = CRM_Utils_Array::value('source_contact_id', $row); } $row['target_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $targetID); $row['assignee_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $assigneeID); list($row['source_contact_name'], $row['source_contact_id']) = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $sourceID, TRUE); $row['source_contact_name'] = implode(',', array_values($row['source_contact_name'])); $row['source_contact_id'] = implode(',', $row['source_contact_id']); if ($this->_context == 'search') { $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->activity_id; } $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id); $accessMailingReport = FALSE; $activityTypeId = $row['activity_type_id']; if ($row['activity_is_test']) { $row['activity_type'] = $row['activity_type'] . " (test)"; } $bulkActivityTypeID = CRM_Utils_Array::key('Bulk Email', $activityTypes); $row['mailingId'] = ''; if ($accessCiviMail && ($mailingIDs === TRUE || in_array($result->source_record_id, $mailingIDs)) && $bulkActivityTypeID == $activityTypeId) { $row['mailingId'] = CRM_Utils_System::url('civicrm/mailing/report', "mid={$result->source_record_id}&reset=1&cid={$contactId}&context=activitySelector"); $row['recipients'] = ts('(recipients)'); $row['target_contact_name'] = ''; $row['assignee_contact_name'] = ''; $accessMailingReport = TRUE; } $activityActions = new CRM_Activity_Selector_Activity($result->contact_id, NULL); $actionLinks = $activityActions->actionLinks($activityTypeId, CRM_Utils_Array::value('source_record_id', $row), $accessMailingReport, CRM_Utils_Array::value('activity_id', $row), $this->_key, $this->_compContext); $row['action'] = CRM_Core_Action::formLink($actionLinks, NULL, array('id' => $result->activity_id, 'cid' => $contactId, 'cxt' => $this->_context), ts('more'), FALSE, 'activity.selector.row', 'Activity', $result->activity_id); //carry campaign to selector. $row['campaign'] = CRM_Utils_Array::value($result->activity_campaign_id, $allCampaigns); $row['campaign_id'] = $result->activity_campaign_id; if ($engagementLevel = CRM_Utils_Array::value('activity_engagement_level', $row)) { $row['activity_engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel); } //Check if recurring activity $repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['activity_id'], 'civicrm_activity'); $row['repeat'] = ''; if ($repeat) { $row['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])); } $rows[] = $row; } return $rows; }
/** * Get list of batches. * * @param array $params * Associated array for params. * * @return array */ public static function getBatchList(&$params) { $whereClause = self::whereClause($params); if (!empty($params['rowCount']) && is_numeric($params['rowCount']) && is_numeric($params['offset']) && $params['rowCount'] > 0) { $limit = " LIMIT {$params['offset']}, {$params['rowCount']} "; } $orderBy = ' ORDER BY batch.id desc'; if (!empty($params['sort'])) { $orderBy = ' ORDER BY ' . CRM_Utils_Type::escape($params['sort'], 'String'); } $query = "\n SELECT batch.*, c.sort_name created_by\n FROM civicrm_batch batch\n INNER JOIN civicrm_contact c ON batch.created_id = c.id\n WHERE {$whereClause}\n {$orderBy}\n {$limit}"; $object = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Batch_DAO_Batch'); if (!empty($params['context'])) { $links = self::links($params['context']); } else { $links = self::links(); } $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id'); $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id'); $batchStatusByName = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name')); $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument(); $results = array(); while ($object->fetch()) { $values = array(); $newLinks = $links; CRM_Core_DAO::storeValues($object, $values); $action = array_sum(array_keys($newLinks)); if ($values['status_id'] == array_search('Closed', $batchStatusByName) && $params['context'] != 'financialBatch') { $newLinks = array(); } elseif ($params['context'] == 'financialBatch') { $values['check'] = "<input type='checkbox' id='check_" . $object->id . "' name='check_" . $object->id . "' value='1' data-status_id='" . $values['status_id'] . "' class='select-row'></input>"; switch ($batchStatusByName[$values['status_id']]) { case 'Open': CRM_Utils_Array::remove($newLinks, 'reopen', 'download'); break; case 'Closed': CRM_Utils_Array::remove($newLinks, 'close', 'edit', 'download'); break; case 'Exported': CRM_Utils_Array::remove($newLinks, 'close', 'edit', 'reopen', 'export'); } } if (!empty($values['type_id'])) { $values['batch_type'] = $batchTypes[$values['type_id']]; } $values['batch_status'] = $batchStatus[$values['status_id']]; $values['created_by'] = $object->created_by; $values['payment_instrument'] = ''; if (!empty($object->payment_instrument_id)) { $values['payment_instrument'] = $paymentInstrument[$object->payment_instrument_id]; } $tokens = array('id' => $object->id, 'status' => $values['status_id']); if ($values['status_id'] == array_search('Exported', $batchStatusByName)) { $aid = CRM_Core_OptionGroup::getValue('activity_type', 'Export Accounting Batch'); $activityParams = array('source_record_id' => $object->id, 'activity_type_id' => $aid); $exportActivity = CRM_Activity_BAO_Activity::retrieve($activityParams, $val); $fid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $exportActivity->id, 'file_id', 'entity_id'); $tokens = array_merge(array('eid' => $exportActivity->id, 'fid' => $fid), $tokens); } $values['action'] = CRM_Core_Action::formLink($newLinks, $action, $tokens, ts('more'), FALSE, 'batch.selector.row', 'Batch', $object->id); $results[$object->id] = $values; } return $results; }
/** * Returns all the rows in the given offset and rowCount. * * @param string $action * The action being performed. * @param int $offset * The row number to start from. * @param int $rowCount * The number of rows to return. * @param string $sort * The sql string that describes the sort order. * @param string $output * What should the result set include (web/email/csv). * * @return array * rows in the given offset and rowCount */ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_eventClause); // process the result of the query $rows = array(); //lets handle view, edit and delete separately. CRM-4418 $permissions = array(CRM_Core_Permission::VIEW); if (CRM_Core_Permission::check('edit event participants')) { $permissions[] = CRM_Core_Permission::EDIT; } if (CRM_Core_Permission::check('delete in CiviEvent')) { $permissions[] = CRM_Core_Permission::DELETE; } $mask = CRM_Core_Action::mask($permissions); $statusTypes = CRM_Event_PseudoConstant::participantStatus(); $statusClasses = CRM_Event_PseudoConstant::participantStatusClass(); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $sep = CRM_Core_DAO::VALUE_SEPARATOR; //get all campaigns. $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); while ($result->fetch()) { $row = array(); // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->{$property})) { $row[$property] = $result->{$property}; } } //carry campaign on selectors. $row['campaign'] = CRM_Utils_Array::value($result->participant_campaign_id, $allCampaigns); $row['campaign_id'] = $result->participant_campaign_id; // gross hack to show extra information for pending status $statusClass = NULL; if (isset($row['participant_status_id']) && ($statusId = array_search($row['participant_status_id'], $statusTypes))) { $statusClass = $statusClasses[$statusId]; } $row['showConfirmUrl'] = $statusClass == 'Pending' ? TRUE : FALSE; if (!empty($row['participant_is_test'])) { $row['participant_status'] .= ' (' . ts('test') . ')'; } $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id; $links = self::links($this->_key, $this->_context, $this->_compContext); if ($statusTypes[$row['participant_status_id']] == 'Partially paid') { $links[CRM_Core_Action::ADD] = array('name' => ts('Record Payment'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Payment')); } if ($statusTypes[$row['participant_status_id']] == 'Pending refund') { $links[CRM_Core_Action::ADD] = array('name' => ts('Record Refund'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Refund')); } $row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $result->participant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context), ts('more'), FALSE, 'participant.selector.row', 'Participant', $result->participant_id); $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id); $row['paid'] = CRM_Event_BAO_Event::isMonetary($row['event_id']); if (!empty($row['participant_fee_level'])) { CRM_Event_BAO_Participant::fixEventLevel($row['participant_fee_level']); } if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) { // add line item details if applicable $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']); } if (!empty($row['participant_role_id'])) { $viewRoles = array(); foreach (explode($sep, $row['participant_role_id']) as $k => $v) { $viewRoles[] = $participantRoles[$v]; } $row['participant_role_id'] = implode(', ', $viewRoles); } $rows[] = $row; } CRM_Core_Selector_Controller::$_template->assign_by_ref('lineItems', $lineItems); return $rows; }