$frameUrl = $CFG->wwwroot . '/mod/' . $mod->mod . '/view.php?id=' . $mod->cm . '&frame=true' . '&mb_url=' . urlencode($pageUrl) . '&mb_title=' . urlencode($titleMb);
 $lang = current_language();
 if (strlen($lang) > 2) {
     $lang = substr($lang, 0, 2);
 }
 include_once $CFG->dirroot . DIRECTORY_SEPARATOR . "mod" . DIRECTORY_SEPARATOR . $study_notes_module_name . DIRECTORY_SEPARATOR . "ext" . DIRECTORY_SEPARATOR . 'config_default.php';
 include_once $CFG->dirroot . DIRECTORY_SEPARATOR . "mod" . DIRECTORY_SEPARATOR . $study_notes_module_name . DIRECTORY_SEPARATOR . "ext" . DIRECTORY_SEPARATOR . 'config.php';
 include_once $CFG->dirroot . DIRECTORY_SEPARATOR . "mod" . DIRECTORY_SEPARATOR . $study_notes_module_name . DIRECTORY_SEPARATOR . "server" . DIRECTORY_SEPARATOR . 'utility.php';
 include_once $CFG->dirroot . DIRECTORY_SEPARATOR . "mod" . DIRECTORY_SEPARATOR . $study_notes_module_name . DIRECTORY_SEPARATOR . "ext" . DIRECTORY_SEPARATOR . 'db_moodle.php';
 include_once $CFG->dirroot . DIRECTORY_SEPARATOR . "mod" . DIRECTORY_SEPARATOR . $study_notes_module_name . DIRECTORY_SEPARATOR . "server" . DIRECTORY_SEPARATOR . 'helper.php';
 $helper = new MediabirdHtmlHelper();
 $moodleid = $USER->id;
 if ($account_link = get_record("studynotes_account_links", "system", "moodle", "external_id", $moodleid)) {
     $mbuser = $account_link->internal_id;
     $mediabirdDb = new MediabirdDboMoodle();
     list($myCards, $theirCards) = $helper->findRelatedNotes($pageUrl, $mbuser);
 }
 if (is_array($myCards) && count($myCards) > 0) {
     $titleString = get_string('edit_my_notes', 'studynotes');
     $iconPath = '/mod/studynotes/ext/launcher-own.png';
     $frameUrl .= "&mb_card_id=" . $myCards[0];
 } else {
     if (is_array($theirCards) && count($theirCards) > 0) {
         $titleString = get_string('edit_their_notes', 'studynotes');
         $iconPath = '/mod/studynotes/ext/launcher-friends.png';
         $frameUrl .= "&mb_card_id=" . $theirCards[0];
     } else {
         $titleString = get_string('take_notes', 'studynotes');
         $iconPath = '/mod/studynotes/ext/launcher-new.png';
     }
 }
Esempio n. 2
0
   public function getDetailActionAsHTML () {
      $retour = '';
      $current_user = $this->_environment->getCurrentUserItem();
      if ( $this->_environment->inPrivateRoom() ) {
         $own_room = $this->_environment->getCurrentContextItem();
      } else {
         $own_room = $current_user->getOwnRoom();
      }
      if ( isset($own_room)
           and !$current_user->isOnlyReadUser()
         ) {

         $system = 'mediabird';

         $url_params = array();
         $url_params['name'] = $system;
         $url_params['SID'] = $this->_environment->getSessionID();
         include_once('functions/security_functions.php');
         $url_params['security_token'] = getToken();
         $url_params['output'] = 'pure';

         $plugin_folder = 'plugins';
         $plugin_name = '/mediabird';
         $plugin_dir = $plugin_folder.$plugin_name;

         $commsyUrl = $this->_getContentLink();

         include_once($plugin_dir.'/config/config_default.php');
         include($plugin_dir.'/config/config.php');
         include_once($plugin_dir.'/server/helper.php');
         include_once($plugin_dir.'/server/utility.php');
         include_once($plugin_dir.'/server/dbo.php');
         include_once($plugin_dir.'/server/db_mysql.php');
         global $mediabirdDb;
         $mediabirdDb = new MediabirdDboMySql();
         $helper = new MediabirdHtmlHelper();

         $userId = $this->_getMBUserID();

         if($mediabirdDb->connect()) {
            $relatedNotes = $helper->findRelatedNotes($commsyUrl,$userId,$mediabirdDb);
            $title = $this->_translator->getMessage('MEDIABIRD_ACTION_ICON_USER_TITLE');
            if($relatedNotes && count($relatedNotes[0])>0) {					// there are own notices
               $card_id = $relatedNotes[0][0];
               $img = ucfirst($this->_translator->getMessage('MEDIABIRD_ACTION_NAME_DETAIL')).' ('.count($relatedNotes[0]).')';
            }
            else { //no related notes yet
               $img = ucfirst($this->_translator->getMessage('MEDIABIRD_ACTION_NAME_DETAIL'));

               //determine the card the user's been to most recently
               if(isset($userId) && ($sessionRecord = $mediabirdDb->getRecord(MediabirdConfig::tableName("Session",true),"user_id=$userId"))) {
                  $card_id = $sessionRecord->card_id;
               }
            }

            $mediabirdDb->disconnect();
         } else {
            $title = $this->_translator->getMessage('MEDIABIRD_ACTION_ICON_USER_TITLE');
            $img = ucfirst($this->_translator->getMessage('MEDIABIRD_ACTION_NAME_DETAIL'));
         }

         $retour = '<a href="javascript:void(0)" id="mediabirdLink" title="'.$title.'">'.$img.'</a>'.LF;

         $frameUrl  = _curl(false,$this->_environment->getCurrentContextID(),$system,'index',$url_params);
         $frameUrl .= "&mb_url=".urlencode($commsyUrl);

         if ( !empty( $card_id ) ) {
            $frameUrl .= "&mb_card_id=".urlencode($card_id);
         }

         $titleHtml = '<div class="title">'.$this->_translator->getMessage('MEDIABIRD_OVERLAY_TITLE').'</div>';

         $retour .= '<div id="mediabirdOverlay" class="mediabird-overlay">'.LF;
         $retour .= '   <div class="bar"><a href="javascript:void(0)" class="closer">X</a><a href="javascript:void(0)" class="expander expanded"></a>'.$titleHtml.'</div>'.LF;
         $retour .= '   <div class="resize-handle right"></div>'.LF;
         $retour .= '   <div class="resize-handle"></div>'.LF;
         $retour .= '   <iframe src="" frameborder="no" scrolling="no" id="mediabirdFrame">'.LF;
         $retour .= '   </iframe>'.LF;
         $retour .= '</div>'.LF;
         $retour .= '<script type="text/javascript" src="'.$plugin_dir.'/js/overlay.js"></script>'.LF;
         $retour .= '<link rel="stylesheet" href="'.$plugin_dir.'/css/overlay_commsy.php?cid='.$this->_environment->getCurrentContextID().'"/>'.LF;
         $retour .= '<script type="text/javascript">'.LF;
         $retour .= '//<![CDATA['.LF;
         $retour .= '   mbOverlay.MAX_HEIGHT = 544;'.LF;
         $retour .= '   mbOverlay.MAX_WIDTH = 685;'.LF;
         $retour .= '   mbOverlay.SIZE_SECURE = 34;'.LF;
         $retour .= '   var url = "'.$frameUrl.'";'.LF;
         $retour .= '   mbOverlay.doIframe(url,document.getElementById("mediabirdLink"),document.getElementById("mediabirdOverlay"),{width:685,height:544},document.getElementById("mediabirdFrame"));'.LF;
         $retour .= '//]]>'.LF;
         $retour .= '</script>'.LF;

      } elseif ( $current_user->isOnlyReadUser() ) {
         $title = $this->_translator->getMessage('COMMON_NO_ACTION_NEW',$this->_translator->getMessage('MEDIABIRD_OVERLAY_TITLE'));
         $img =  '<img src="'.$this->getActionNotActiveIcon().'" style="vertical-align:bottom;" title="'.$title.'"/>';
         $retour =  $img.LF;
      } else {
         $title = $this->_translator->getMessage('MEDIABIRD_ACTION_ICON_NOT_ACTIVE_TITLE');
         $img =  '<img src="'.$this->getActionNotActiveIcon().'" style="vertical-align:bottom;" title="'.$title.'"/>';
         $retour =  $img.LF;
      }
      return $retour;
   }