if (empty($_COOKIE)) {
    error(get_string('cookies_required', 'studynotes'));
    return;
}
if (!version_compare(PHP_VERSION, '5.2.0', '>=')) {
    error(get_string('wrong_php_version', 'studynotes'));
    return;
}
$moodleid = $USER->id;
$email = $USER->email;
$fullname = $USER->firstname . ' ' . $USER->lastname;
if (strlen(trim($fullname)) == 0) {
    $fullname = $USER->username;
}
$mediabirdDb = new MediabirdDboMoodle();
$helper = new MediabirdHtmlHelper();
unset($action);
if (isset($_POST["data"]) && isset($_POST["data"]["action"])) {
    $action = $_POST["data"]["action"];
} else {
    if (isset($_GET["action"])) {
        $action = $_GET["action"];
    }
}
if ($account_link = get_record("studynotes_account_links", "system", "moodle", "external_id", $moodleid)) {
    $mbuser = $account_link->internal_id;
    if (!isset($action)) {
        $helper->updateUser($mbuser, $fullname, 1, $email);
    }
} else {
    if ($mbuser = $helper->registerUser($fullname, 1, $email)) {
Example #2
0
$plugin_dir = $plugin_folder.$plugin_name;
$external_id_manager = $environment->getExternalIDManager();
$system = 'mediabird';
$language = $environment->getSelectedLanguage();
$commsy_mediabird = $environment->getPluginClass($system);

// mediabird: start
include($plugin_dir.'/server/helper.php');
include($plugin_dir.'/config/config_default.php');
include($plugin_dir.'/config/config.php');
include ($plugin_dir.'/server/dbo.php');

include($plugin_dir.'/server/utility.php');

// create a helper instance (having to do this after the static function calls since config has not been loaded otherwise)
$helper = new MediabirdHtmlHelper();
include_once($plugin_dir.'/server/db_mysql.php');
$mediabirdDb = new MediabirdDboMySql();
if ( !$mediabirdDb->connect() ) {
   include_once('function/error_function.php');
   trigger_error('cannot open database - aborting execution',E_USER_ERROR);
   exit();
}

// Uebersetzungstabelle commsy -> mediabird
$current_user_item = $environment->getCurrentUserItem();
$portal_user_item = $current_user_item->getRelatedCommSyUserItem();

// last login
include_once('functions/date_functions.php');
$current_user_item->setLastLoginPlugin(getCurrentDateTimeInMySQL(),$system);
Example #3
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;
   }
 $pageUrl = $CFG->pagepath . "?id=" . $id;
 $titleMb = $title;
 if (strlen($titleMb) > 80) {
     $titleMb = substr($titleMb, 0, 77) . "...";
 }
 $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];
Example #5
0
   /**
    * Called to invite a user to Mediabird
    * Should return a Mediabird user ID or null on failure (email not unique or does not exist)
    * @param $email String Email of user to be invited
    * @return int Mediabird user id
    */
   function inviteUser ($email) {
      $retour = NULL;
      if ( !empty($email) ) {
         $user_manager = $this->_environment->getUserManager();
         $user_manager->setContextLimit($this->_environment->getCurrentPortalID());
         $user_manager->setEMailLimit($email);
         $user_manager->select();
         $user_list = $user_manager->get();
         if ( isset($user_list)
              and $user_list->isNotEmpty()
              and $user_list->getCount() == 1
            ) {
            $user_item = $user_list->getFirst();
            if ( isset($user_item)
                 and $user_item->isEmailVisible()
               ) {
               $external_id_manager = $this->_environment->getExternalIDManager();
               $mbuser = $external_id_manager->getExternalId($this->_system,$user_item->getItemID());
               $fullname = $user_item->getFullname();

               global $plugin_dir;
               include($plugin_dir.'/server/helper.php');
               $helper = new MediabirdHtmlHelper();

               if ( empty($mbuser) ) {
                  #$pic_url = $user_item->getPictureUrl(true);
                  if ( !empty($user_item) ) {
                     $pic_url = $this->_plugin_class->getPictureUrlForCommSyUserByItem($user_item);
                  }
                  $email = null;

                  if ( $user_item->isEmailVisible() ) {
                     $email = $user_item->getEMail();
                  }

                  $mbuser = $helper->registerUser($fullname, 0, $email, $pic_url, $this->db);
                  $external_id_manager->addIDsToDB($this->_system,$mbuser,$user_item->getItemID());
               }
               unset($external_id_manager);
               $retour = intval($mbuser);
            }
         }
      }
      return $retour;
   }