/**
  * Creates a link documentation help link for a given menu section. If
  * section has no help assigned or section is null link to main help is
  * returned.
  *
  * @param OA_Admin_Menu_Section $menuSection menu section to find help for
  * @return string url to documentation page
  */
 function getHelpLink($menuSection)
 {
     if ($menuSection != null) {
         $relativeHelpPath = $menuSection->getHelpLink();
     } else {
         $relativeHelpPath = "";
     }
     // The link is not relative, we directly link to it
     if (strpos($relativeHelpPath, '://') !== false) {
         return $relativeHelpPath;
     }
     // Convert original help links to new Revive Adserver format
     if (strpos($relativeHelpPath, 'settings') !== false) {
         if (strpos($relativeHelpPath, '/') !== 0) {
             $relativeHelpPath = '/admin/' . $relativeHelpPath;
         } else {
             $relativeHelpPath = '/admin' . $relativeHelpPath;
         }
     } else {
         if (strpos($relativeHelpPath, '/') !== 0) {
             $relativeHelpPath = '/user/' . $relativeHelpPath;
         } else {
             $relativeHelpPath = '/user' . $relativeHelpPath;
         }
     }
     return OA_Admin_Help::buildHelpLink($relativeHelpPath);
 }
Exemple #2
0
 /**
  * Creates a link documentation help link for a given menu section. If section has no help assigned or section is null 
  * link to main help is returned 
  *
  * @param OA_Admin_Menu_Section $menuSection menu section to find help for
  * @return string url to documentation page
  */
 function getHelpLink($menuSection)
 {
     if ($menuSection != null) {
         $relativeHelpPath = $menuSection->getHelpLink();
     } else {
         $relativeHelpPath = "";
     }
     return OA_Admin_Help::buildHelpLink($relativeHelpPath);
 }
 /**
  * Need to do checks manually, PHP fails on circular references between
  * section and its parent
  *
  * @param OA_Admin_Menu_Section $section1
  * @param OA_Admin_Menu_Section $section2
  */
 function assertSectionsEqual($section1, $section2)
 {
     $this->assertEqual($section1->getId(), $section2->getId());
     $this->assertEqual($section1->getName(), $section2->getName());
     $this->assertEqual($section1->getLink(array()), $section2->getLink(array()));
     $this->assertEqual($section1->getHelpLink(), $section2->getHelpLink());
     $this->assertEqual($section1->getRank(), $section2->getRank());
     $this->assertEqual($section1->isExclusive(), $section2->isExclusive());
     $this->assertEqual($section1->isAffixed(), $section2->isAffixed());
     $this->assertEqual($section1->getChecker(), $section2->getChecker());
 }
 /**
  * @param OA_Admin_Menu_Section $oSection
  */
 public function check($oSection)
 {
     // this checker is called 6 times, not sure why, but we cache the lookup in a static variable
     static $cache = array();
     if (isset($cache[$oSection->getId()])) {
         return $cache[$oSection->getId()];
     }
     $enabled = false;
     require_once MAX_PATH . '/www/admin/plugins/videoReport/stats-api.php';
     $vast = new OX_Video_Report();
     phpAds_registerGlobal('clientid', 'campaignid', 'bannerid', 'zoneid');
     global $clientid, $campaignid, $bannerid, $zoneid, $affiliateid;
     //        echo "<pre>";debug_print_backtrace();
     switch ($oSection->getId()) {
         case 'stats-vast-advertiser':
             $enabled = $vast->doesAdvertiserHaveVast((int) $clientid);
             break;
         case 'stats-vast-campaign':
             $enabled = $vast->doesCampaignHaveVast((int) $campaignid);
             break;
         case 'stats-vast-banner':
             $enabled = $vast->doesBannerHaveVast((int) $bannerid);
             break;
         case 'stats-vast-zone':
             $enabled = $vast->isZoneVast((int) $zoneid);
             break;
         case 'stats-vast-website':
             $enabled = $vast->doesWebsiteHaveVast((int) $affiliateid);
             break;
         case 'players-vast':
             return true;
             break;
         case 'zone-invocation':
             if (!empty($zoneid) && $vast->isZoneVast((int) $zoneid)) {
                 $oSection->setNameKey('Video Invocation Code');
                 $oSection->setLink('plugins/videoReport/zone-invocation-code.php?zoneid=' . (int) $zoneid . '&affiliateid=' . (int) $affiliateid);
             }
             $enabled = true;
             break;
     }
     $cache[$oSection->getId()] = $enabled;
     return $enabled;
 }
 /**
  * Inserts new section after the section with the specified id. If the section
  * with the specified id does not exists MAX::raiseError is returned.
  *
  * @param String $existingSectionId
  * @param OA_Admin_Menu_Section $newSection
  */
 function insertAfter($existingSectionId, &$newSection)
 {
     if (!isset($this->aSectionsMap[$existingSectionId])) {
         $errMsg = "MenuSection::insertAfter() Cannot insert section '" . $newSection->getId() . "' after a non existent menu section with id '" . $existingSectionId . "'";
         return MAX::raiseError($errMsg);
     }
     //check if added section is unique in menu
     if (isset($this->aSectionsMap[$newSection->getId()])) {
         $errMsg = "MenuSection::insertAfter() Cannot insert section '" . $newSection->getId() . "': section with given id already exists";
         return MAX::raiseError($errMsg);
     }
     $sectionIndex = $this->_getSectionIndex($existingSectionId, $this->aSections);
     array_insert($this->aSections, $sectionIndex + 1, $newSection);
     $newSection->setParent($this);
     $this->_addToHash($newSection);
     return true;
 }
Exemple #6
0
 /**
  * Adds a given section to a section with given id.
  * Add new section as a top level section. If add was successful true is
  * returned. Error is retunred when element cannot because:
  * - there is no such sectin with $parentSectionId to add to
  * - section with given id already exists in the tree
  *
  * @param String $parentSectionId parent id
  * @param OA_Admin_Menu_Section $section section to be added
  * @return true if element was added, MAX:raiseError() in case it fails.
  */
 function addTo($parentSectionId, &$section)
 {
     if ($parentSectionId == $this->ROOT_SECTION_ID) {
         $parentSection =& $this->rootSection;
     } else {
         if (array_key_exists($parentSectionId, $this->aAllSections)) {
             //TODO replace with isset($this->aAllSections[$parentSectionId])
             $parentSection =& $this->aAllSections[$parentSectionId];
         } else {
             $errMsg = "Menu::addTo() Cannot add section '" . $section->getId() . "' to a non existent menu section with id '" . $parentSectionId . "'";
             return MAX::raiseError($errMsg);
         }
     }
     //check if added section is unique in menu
     if (array_key_exists($section->getId(), $this->aAllSections)) {
         $errMsg = "Menu::addTo() Cannot add section '" . $section->getId() . "' to section '" . $parentSectionId . "'. Section with given id already exists";
         return MAX::raiseError($errMsg);
     }
     //add to parent
     $parentSection->add($section);
     //add new section to hash array
     $this->_addToHash($section);
     return true;
     //TODO return added section here
 }