/**
  * Association of members
  *
  * @param   int  $memberid  The Member item id
  *
  * @since 1.7.5
  *
  * @return mixed
  */
 public static function association($memberid)
 {
     // Get the associations
     $associations = ChurchDirectoryHelper::getAssociations($memberid);
     foreach ($associations as $tag => $associated) {
         $associations[$tag] = (int) $associated->id;
     }
     // Get the associated contact items
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('c.*');
     $query->from('#__contact_details as c');
     $query->select('cat.title as category_title');
     $query->leftJoin('#__categories as cat ON cat.id=c.catid');
     $query->where('c.id IN (' . implode(',', array_values($associations)) . ')');
     $query->leftJoin('#__languages as l ON c.language=l.lang_code');
     $query->select('l.image');
     $query->select('l.title as language_title');
     $db->setQuery($query);
     $items = $db->loadObjectList('id');
     // Check for a database error.
     if ($error = $db->getErrorMsg()) {
         JError::raiseWarning(500, $error);
         return false;
     }
     // Construct html
     $text = [];
     foreach ($associations as $tag => $associated) {
         if ($associated != $memberid) {
             $text[] = JText::sprintf('COM_CHURCHDIRECTORY_TIP_ASSOCIATED_LANGUAGE', JHtml::_('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, ['title' => $items[$associated]->language_title], true), $items[$associated]->name, $items[$associated]->category_title);
         }
     }
     return JHtml::_('tooltip', implode('<br />', $text), JText::_('COM_CHURCHDIRECTORY_TIP_ASSOCIATION'), 'admin/icon-16-links.png');
 }
 /**
  * Add the page title and toolbar.
  *
  * @since    1.7.0
  *
  * @return void
  */
 protected function addToolbar()
 {
     $canDo = ChurchDirectoryHelper::getActions('com_churchdirectory', 'familyunit');
     $user = JFactory::getUser();
     JToolbarHelper::title(JText::_('COM_CHURCHDIRECTORY_MANAGER_FAMILYUNITS'), 'churchdirectory');
     if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_churchdirectory', 'core.create')) > 0) {
         JToolbarHelper::addNew('familyunit.add');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolbarHelper::editList('familyunit.edit');
     }
     if ($canDo->get('core.edit.state')) {
         JToolbarHelper::divider();
         JToolbarHelper::publish('familyunits.publish', 'JTOOLBAR_PUBLISH', true);
         JToolbarHelper::unpublish('familyunits.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolbarHelper::divider();
         JToolbarHelper::checkin('familyunits.checkin');
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolbarHelper::deleteList('', 'familyunits.delete', 'JTOOLBAR_EMPTY_TRASH');
         JToolbarHelper::divider();
     } elseif ($canDo->get('core.edit.state')) {
         JToolbarHelper::trash('familyunits.trash');
         JToolbarHelper::divider();
     }
     if ($canDo->get('core.admin')) {
         JToolbarHelper::preferences('com_churchdirectory');
         JToolbarHelper::divider();
     }
     JToolbarHelper::help('churchdirectory_familyunit', true);
     JHtmlSidebar::setAction('index.php?option=com_churchdirectory&amp;view=familyunits');
 }
 /**
  * Add the page title and toolbar.
  *
  * @since    1.7.0
  * @return void
  */
 protected function addToolbar()
 {
     JFactory::getApplication()->input->set('hidemainmenu', true);
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     $canDo = ChurchDirectoryHelper::getActions('com_churchdirectory', 'kml', $this->item->id);
     JToolbarHelper::title($isNew ? JText::_('COM_CHURCHDIRECTORY_MANAGER_KML_NEW') : JText::_('COM_CHURCHDIRECTORY_MANAGER_KML_EDIT'), 'kml');
     // Build the actions for new and existing records.
     if ($isNew) {
         // For new records, check the create permission.
         if ($isNew && count($user->getAuthorisedCategories('com_churchdirectory', 'core.create')) > 0) {
             JToolbarHelper::apply('kml.apply');
             JToolbarHelper::save('kml.save');
         }
         JToolbarHelper::cancel('kml.cancel');
     } else {
         // Can't save the record if it's checked out.
         if (!$checkedOut) {
             // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
             if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) {
                 JToolbarHelper::apply('kml.apply');
                 JToolbarHelper::save('kml.save');
             }
         }
         JToolbarHelper::cancel('kml.cancel', 'JTOOLBAR_CLOSE');
     }
     JToolbarHelper::divider();
     JToolbarHelper::help('churchdirectory_kml', true);
 }
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @since    1.7.0
  */
 protected function addToolbar()
 {
     $canDo = ChurchDirectoryHelper::getActions();
     JToolbarHelper::title(JText::_('COM_CHURCHDIRECTORY_DATABASE'), 'puzzle install');
     JToolbarHelper::divider();
     if ($canDo) {
         JToolbarHelper::custom('database.fix', 'refresh', 'refresh', 'COM_CHURCHDIRECTORY_DATABASE_FIX', false);
     }
 }
 /**
  * Add the page title and toolbar.
  *
  * @since    1.7.0
  * @return void
  */
 protected function addToolbar()
 {
     $canDo = ChurchDirectoryHelper::getActions('com_churchdirectory');
     JToolbarHelper::title(JText::_('COM_CHURCHDIRECTORY_MANAGER_CPANEL'), 'address contact');
     if ($canDo->get('core.admin')) {
         JToolbarHelper::divider();
         JToolbarHelper::preferences('com_churchdirectory');
         JToolbarHelper::divider();
     }
     JToolbarHelper::help('churchdirectory', true);
 }
 /**
  * Add the page title and toolbar.
  *
  * @since    1.7.0
  * @return void
  */
 protected function addToolbar()
 {
     $canDo = ChurchDirectoryHelper::getActions();
     // Get the toolbar object instance
     $bar = JToolbar::getInstance('toolbar');
     // Set the toolbar title
     JToolbarHelper::title(JText::_('COM_CHURCHDIRECTORY_TITLE_GEOUPDATE_STATUS'), 'geo');
     $bar->appendButton('Popup', 'refresh', 'COM_CHURCHDIRECTORY_GEOUPDATE', 'index.php?option=com_churchdirectory&view=geoupdate&tmpl=component', 550, 350);
     if ($canDo->get('core.admin')) {
         JToolbarHelper::preferences('com_churchdirectory');
     }
     JToolbarHelper::help('churchdirectory_geoupdate', true);
 }
 /**
  * Display function
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  *
  * @since    1.7.0
  */
 public function display($tpl = null)
 {
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     ChurchDirectoryHelper::addSubmenu('info');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JFactory::getApplication()->enqueueMessage(implode("\n", $errors), 'error');
         return false;
     }
     $this->addToolbar();
     $this->sidebar = JHtmlSidebar::render();
     // Display the template
     return parent::display($tpl);
 }
 /**
  * Add the page title and toolbar.
  *
  * @since    1.7.0
  *
  * @return void
  */
 protected function addToolbar()
 {
     $canDo = ChurchDirectoryHelper::getActions($this->state->get('filter.category_id'));
     $user = JFactory::getUser();
     // Get the toolbar object instance
     $bar = JToolbar::getInstance('toolbar');
     JToolbarHelper::title(JText::_('COM_CHURCHDIRECTORY_MANAGER_DIRHEADERS'), 'churchdirectory');
     if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_churchdirectory', 'core.create')) > 0) {
         JToolbarHelper::addNew('dirheader.add');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolbarHelper::editList('dirheader.edit');
     }
     if ($canDo->get('core.edit.state')) {
         JToolbarHelper::divider();
         JToolbarHelper::publish('dirheaders.publish', 'JTOOLBAR_PUBLISH', true);
         JToolbarHelper::unpublish('dirheaders.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolbarHelper::divider();
         JToolbarHelper::checkin('dirheaders.checkin');
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolbarHelper::deleteList('', 'dirheaders.delete', 'JTOOLBAR_EMPTY_TRASH');
     } elseif ($canDo->get('core.edit.state')) {
         JToolbarHelper::trash('dirheaders.trash');
     }
     if (version_compare(JVERSION, '3.0.0', 'ge')) {
         // Add a batch button
         if ($user->authorise('core.edit')) {
             JHtml::_('bootstrap.modal', 'collapseModal');
             $title = JText::_('JTOOLBAR_BATCH');
             $dhtml = "<button data-toggle=\"modal\" data-target=\"#collapseModal\" class=\"btn btn-small\">\n\t\t\t\t\t\t<i class=\"icon-checkbox-partial\" title=\"{$title}\"></i>\n\t\t\t\t\t\t{$title}</button>";
             $bar->appendButton('Custom', $dhtml, 'batch');
         }
     }
     if ($canDo->get('core.admin')) {
         JToolbarHelper::preferences('com_churchdirectory');
     }
     JToolbarHelper::help('churchdirectory_dirheader', true);
     JHtmlSidebar::setAction('index.php?option=com_churchdirectory&amp;view=dirheaders');
 }
 /**
  * Add the page title and toolbar.
  *
  * @since    1.7.0
  *
  * @return void
  */
 protected function addToolbar()
 {
     $user = JFactory::getUser();
     $canDo = ChurchDirectoryHelper::getActions('com_churchdirectory');
     JToolbarHelper::title(JText::_('COM_CHURCHDIRECTORY_MANAGER_POSITIONS'), 'churchdirectory');
     if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_churchdirectory', 'core.create')) > 0) {
         JToolbarHelper::addNew('position.add');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolbarHelper::editList('position.edit');
     }
     if ($canDo->get('core.edit.state')) {
         JToolbarHelper::publish('positions.publish', 'JTOOLBAR_PUBLISH', true);
         JToolbarHelper::unpublish('positions.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolbarHelper::archiveList('positions.archive');
         JToolbarHelper::checkin('positions.checkin');
     }
     // Add a batch button
     if ($user->authorise('core.create', 'com_churchdirectory') && $user->authorise('core.edit', 'com_churchdirectory') && $user->authorise('core.edit.state', 'com_churchdirectory')) {
         $title = JText::_('JTOOLBAR_BATCH');
         // Instantiate a new JLayoutFile instance and render the batch button
         $layout = new JLayoutFile('joomla.toolbar.batch');
         $dhtml = $layout->render(array('title' => $title));
         JToolbar::getInstance('toolbar')->appendButton('Custom', $dhtml, 'batch');
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolbarHelper::deleteList('', 'positions.delete', 'JTOOLBAR_EMPTY_TRASH');
     } elseif ($canDo->get('core.edit.state')) {
         JToolbarHelper::trash('positions.trash');
     }
     if ($canDo->get('core.admin', 'com_churchdirectory') || $user->authorise('core.options', 'com_churchdirectory')) {
         JToolbarHelper::preferences('com_churchdirectory');
     }
     JToolbarHelper::help('churchdirectory_position', true);
     JHtmlSidebar::setAction('index.php?option=com_churchdirectory&amp;view=positions');
 }
 /**
  * Add the page title and toolbar.
  *
  * @since    1.7.0
  * @return void
  */
 protected function addToolbar()
 {
     JFactory::getApplication()->input->set('hidemainmenu', true);
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     $canDo = ChurchDirectoryHelper::getActions('com_churchdirectory', 'category', $this->item->catid);
     JToolbarHelper::title($isNew ? JText::_('COM_CHURCHDIRECTORY_MANAGER_MEMBER_NEW') : JText::_('COM_CHURCHDIRECTORY_MANAGER_MEMBER_EDIT'), 'address contact');
     // Build the actions for new and existing records.
     if ($isNew) {
         // For new records, check the create permission.
         if ($isNew && count($user->getAuthorisedCategories('com_churchdirectory', 'core.create')) > 0) {
             JToolbarHelper::apply('member.apply');
             JToolbarHelper::save('member.save');
             JToolbarHelper::save2new('member.save2new');
         }
         JToolbarHelper::cancel('member.cancel');
     } else {
         // Can't save the record if it's checked out.
         if (!$checkedOut) {
             // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
             if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) {
                 JToolbarHelper::apply('member.apply', 'JTOOLBAR_APPLY');
                 JToolbarHelper::save('member.save', 'JTOOLBAR_SAVE');
                 // We can save this record, but check the create permission to see if we can return to make a new one.
                 if ($canDo->get('core.create')) {
                     JToolbarHelper::save2new('member.save2new');
                 }
             }
         }
         // If checked out, we can still save
         if ($canDo->get('core.create')) {
             JToolbarHelper::save2copy('member.save2copy');
         }
         JToolbarHelper::cancel('member.cancel', 'JTOOLBAR_CLOSE');
     }
     JToolbarHelper::divider();
     JToolbarHelper::help('member_contact', true);
 }