Exemplo n.º 1
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $smsNumbers = CRM_Contact_BAO_Contact::allPhones($cid, 'Mobile');
         $this->_emails = array();
         $toName = CRM_Contact_BAO_Contact::displayName($cid);
         foreach ($smsNumbers as $number => $item) {
             $this->_smsNumbers[$number] = '"' . $toName . '" <' . $number . '> ' . $item['locationType'];
             if ($item['is_primary']) {
                 $this->_smsNumbers[$number] .= ' ' . ts('(preferred)');
             }
             $this->_smsNumbers[$number] = htmlspecialchars($this->_emails[$email]);
         }
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
Exemplo n.º 2
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     $id = CRM_Utils_Request::retrieve('id', $this);
     $dao =& new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('SMS Sent');
     if ($dao->find(true)) {
         $cid = $dao->entity_id;
     }
     require_once 'CRM/SMS/DAO/History.php';
     $dao =& new CRM_SMS_DAO_History();
     $dao->id = $id;
     if ($dao->find(true)) {
         $this->assign('fromName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contact_id, 'display_name'));
         $this->assign('toName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'));
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         require_once 'CRM/Utils/Menu.php';
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         require_once 'CRM/Core/BAO/CustomGroup.php';
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
     }
     parent::run();
 }
Exemplo n.º 3
0
 function run()
 {
     require_once 'CRM/Utils/Menu.php';
     $items =& CRM_Utils_Menu::items();
     $config =& CRM_Core_Config::singleton();
     $groups = array(ts('Manage'), ts('Configure'), ts('Setup'));
     if (in_array("CiviContribute", $config->enableComponents)) {
         $groups[] = 'CiviContribute';
     }
     $adminPanel = array();
     foreach ($groups as $group) {
         $adminPanel[$group] = array();
         foreach ($items as $item) {
             if ($config->userFramework == 'Mambo' && $item['path'] == 'civicrm/admin/access') {
                 // access control not yet implemented for mambo
                 continue;
             }
             if (CRM_Utils_Array::value('adminGroup', $item) == $group) {
                 $value = array('title' => $item['title'], 'url' => CRM_Utils_System::url($item['path'], CRM_Utils_Array::value('qs', $item)), 'icon' => $item['icon'], 'extra' => CRM_Utils_Array::value('extra', $item));
                 $adminPanel[$group][$item['weight'] . '.' . $item['title']] = $value;
             }
         }
         ksort($adminPanel[$group]);
     }
     require_once 'CRM/Utils/VersionCheck.php';
     $versionCheck =& CRM_Utils_VersionCheck::singleton();
     $this->assign('newVersion', $versionCheck->newerVersion());
     $this->assign('localVersion', $versionCheck->localVersion);
     $this->assign('adminPanel', $adminPanel);
     return parent::run();
 }
Exemplo n.º 4
0
 /** 
  * build all the data structures needed to build the form 
  * 
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $this->assign('totalSelectedContacts', 1);
     } else {
         parent::preProcess();
     }
 }
Exemplo n.º 5
0
 /**
  *
  * This function does 2 things - 
  *   1 - Create menu tabs for all custom groups with style 'Tab'
  *   2 - Updates tab for custom groups with style 'Inline'. If there
  *       are no inline groups it removes the 'Custom Data' tab
  *
  *
  * @param string $entityType  - what entity are we extending here ?
  * @param string $path        - what should be the starting path for the new menus ?
  * @param int    $startWeight - weight to start the local menu tabs
  *
  * @return void
  *
  * @access public
  * @static
  *
  */
 function addMenuTabs($entityType, $path, $startWeight)
 {
     // for Tab's
     $customGroupDAO =& new CRM_Core_DAO_CustomGroup();
     // get only 'Tab' groups
     $customGroupDAO->whereAdd("style = 'Tab'");
     $customGroupDAO->whereAdd("is_active = 1");
     $customGroupDAO->whereAdd("domain_id =" . CRM_Core_Config::domainID());
     // add whereAdd for entity type
     CRM_Core_BAO_CustomGroup::_addWhereAdd($customGroupDAO, $entityType);
     // order by weight
     $customGroupDAO->orderBy('weight');
     $customGroupDAO->find();
     // process each group with menu tab
     while ($customGroupDAO->fetch()) {
         $menu = array();
         $menu['path'] = $path;
         $menu['title'] = "{$customGroupDAO->title}";
         $menu['qs'] = 'reset=1&gid=' . $customGroupDAO->id . '&cid=%%cid%%';
         $menu['type'] = CRM_UTILS_MENU_CALLBACK;
         $menu['crmType'] = CRM_UTILS_MENU_LOCAL_TASK;
         $menu['weight'] = $startWeight++;
         $menu['extra'] = array('gid' => $customGroupDAO->id);
         $menus[] = $menu;
     }
     if (is_array($menus)) {
         foreach ($menus as $menu) {
             CRM_Utils_Menu::add($menu);
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  * @access public
  *
  */
 function preProcess()
 {
     $this->_id = CRM_Utils_Request::retrieve('id', $this);
     $this->assign('id', $this->_id);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', $this, true);
     if (!$this->_contactId) {
         CRM_Utils_System::statusBounce(ts('We could not find a contact id.'));
     }
     $this->assign('contactId', $this->_contactId);
     $this->_action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     $this->assign('action', $this->_action);
     // check for permissions
     $this->_permission = null;
     if (CRM_Contact_BAO_Contact::permissionedContact($this->_contactId, CRM_CORE_PERMISSION_EDIT)) {
         $this->assign('permission', 'edit');
         $this->_permission = CRM_CORE_PERMISSION_EDIT;
     } else {
         if (CRM_Contact_BAO_Contact::permissionedContact($this->_contactId, CRM_CORE_PERMISSION_VIEW)) {
             $this->assign('permission', 'view');
             $this->_permission = CRM_CORE_PERMISSION_VIEW;
         } else {
             CRM_Utils_System::statusBounce(ts('You do not have the necessary permission to view this contact.'));
         }
     }
     $this->getContactDetails();
     $contactImage = $this->get('contactImage');
     $displayName = $this->get('displayName');
     $this->assign('displayName', $displayName);
     CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
     CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId), $contactImage, $this->_contactId);
     // also add the cid params to the Menu array
     CRM_Utils_Menu::addParam('cid', $this->_contactId);
     $this->assign('viewForm', $form);
     $this->assign('showBlocks1', $showBlocks);
     $this->assign('hideBlocks1', $hideBlocks);
     $this->assign('groupTree', $_groupTree);
     //------------
     // create menus ..
     $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
     $startWeight++;
     CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($this->_contactId), 'civicrm/contact/view/cd', $startWeight);
     //display OtherActivity link
     $otherAct = CRM_Core_PseudoConstant::activityType(false);
     $activityNum = count($otherAct);
     $this->assign('showOtherActivityLink', $activityNum);
 }
Exemplo n.º 7
0
 /**
  * create the list of shortcuts for the application and format is as a block
  *
  * @return void
  * @access private
  */
 function setTemplateMenuValues()
 {
     $config =& CRM_Core_Config::singleton();
     $items =& CRM_Utils_Menu::items();
     $values = array();
     foreach ($items as $item) {
         if (!CRM_Utils_Array::value('crmType', $item)) {
             continue;
         }
         if ($item['crmType'] & CRM_UTILS_MENU_NORMAL_ITEM && $item['crmType'] >= CRM_UTILS_MENU_NORMAL_ITEM && $item['access']) {
             $value = array();
             $value['url'] = CRM_Utils_System::url($item['path'], CRM_Utils_Array::value('qs', $item));
             $value['title'] = $item['title'];
             $value['path'] = $item['path'];
             $value['class'] = 'leaf';
             $value['parent'] = null;
             $value['start'] = $value['end'] = null;
             if (strpos(CRM_Utils_Array::value($config->userFrameworkURLVar, $_REQUEST), $item['path']) === 0) {
                 $value['active'] = 'class="active"';
             } else {
                 $value['active'] = '';
             }
             // check if there is a parent
             foreach ($values as $weight => $v) {
                 if (strpos($item['path'], $v['path']) !== false) {
                     $value['parent'] = $weight;
                     // only reset if still a leaf
                     if ($values[$weight]['class'] == 'leaf') {
                         $values[$weight]['class'] = 'collapsed';
                     }
                     // if a child or the parent is active, expand the menu
                     if ($value['active'] || $values[$weight]['active']) {
                         $values[$weight]['class'] = 'expanded';
                     }
                     // make the parent inactive if the child is active
                     if ($value['active'] && $values[$weight]['active']) {
                         $values[$weight]['active'] = '';
                     }
                 }
             }
             $values[$item['weight'] . '.' . $item['title']] = $value;
         }
     }
     // remove all collapsed menu items from the array
     $activeChildren = array();
     foreach ($values as $weight => $v) {
         if ($v['parent']) {
             if ($values[$v['parent']]['class'] == 'collapsed') {
                 unset($values[$weight]);
             } else {
                 $activeChildren[] = $weight;
             }
         }
     }
     // add the start / end tags
     $len = count($activeChildren) - 1;
     if ($len >= 0) {
         $values[$activeChildren[0]]['start'] = true;
         $values[$activeChildren[$len]]['end'] = true;
     }
     ksort($values);
     CRM_Core_Block::setProperty(CRM_CORE_BLOCK_MENU, 'templateValues', array('menu' => $values));
 }
Exemplo n.º 8
0
 /**
  * executes & returns or displays the template results
  *
  * @param string $resource_name
  * @param string $cache_id
  * @param string $compile_id
  * @param boolean $display
  */
 function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
 {
     require_once 'CRM/Utils/Menu.php';
     // hack for now, we need to execute this at the end to allow the modules to
     // add new menu items etc, this CANNOT go in the smarty constructor
     $config =& CRM_Core_Config::singleton();
     CRM_Utils_Menu::createLocalTasks($_GET[$config->userFrameworkURLVar]);
     return parent::fetch($resource_name, $cache_id, $compile_id, $display);
 }
Exemplo n.º 9
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     $id = CRM_Utils_Request::retrieve('id', $this);
     $dao =& new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('Email Sent');
     if ($dao->find(true)) {
         $cid = $dao->entity_id;
     }
     $dao =& new CRM_Core_DAO_EmailHistory();
     $dao->id = $id;
     if ($dao->find(true)) {
         // get the display name and email for the contact
         list($toContactName, $toContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($cid);
         if (!trim($toContactName)) {
             $toContactName = $toContactEmail;
         }
         if (trim($toContactEmail)) {
             $toContactName = "\"{$toContactName}\" <{$toContactEmail}>";
         }
         $this->assign('toName', $toContactName);
         // get the display name and email for the contact
         list($fromContactName, $fromContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($dao->contact_id);
         if (!trim($fromContactEmail)) {
             CRM_Utils_System::statusBounce(ts('Your user record does not have a valid email address'));
         }
         if (!trim($fromContactName)) {
             $fromContactName = $fromContactEmail;
         }
         $this->assign('fromName', "\"{$fromContactName}\" <{$fromContactEmail}>");
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('subject', $dao->subject);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         require_once 'CRM/Utils/Menu.php';
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         require_once 'CRM/Core/BAO/CustomGroup.php';
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
     }
     parent::run();
 }
Exemplo n.º 10
0
 /**
  * Get max weight for a path
  *
  * @param  string $path  parent menu path
  *
  * @return int    max weight for the path           
  *
  * @static
  * @access public
  */
 function getMaxWeight($path)
 {
     $path = trim($path, '/');
     // since we need children only
     $path .= '/';
     $maxWeight = -1024;
     // weights can have -ve numbers hence cant initialize it to 0
     $firstChild = true;
     foreach (CRM_Utils_Menu::items() as $menu) {
         if (strpos($menu['path'], $path) === 0) {
             if ($firstChild) {
                 // maxWeight is initialized to the weight of the first child
                 $maxWeight = $menu['weight'];
                 $firstChild = false;
             } else {
                 $maxWeight = $menu['weight'] > $maxWeight ? $menu['weight'] : $maxWeight;
             }
         }
     }
     return $maxWeight;
 }