/** * The function shortens a string, but it uses the first 2/3 and the last 1/3 * * The parts will be divided by a "[...]". The functions is to use like php's * substr function. * * @param string $what the original string * @param integer $start start pos, 0 is the first pos * @param integer $end end pos * * @return string * * */ function my_substr($what, $start, $end) { $length = $end - $start; $what_length = studip_strlen($what); // adding 5 because: strlen("[...]") == 5 if ($what_length > $length + 5) { $what = studip_substr($what, $start, round($length / 3 * 2)) . "[...]" . studip_substr($what, $what_length - round($length / 3), $what_length); } return $what; }
/** * sends a message to all members of a studygroup * * @param string id of a studygroup * * @return void */ function message_action($id) { $sem = Course::find($id); if (studip_strlen($sem->getFullname()) > 32) { //cut subject if to long $subject = sprintf(_("[Studiengruppe: %s...]"), studip_substr($sem->getFullname(), 0, 30)); } else { $subject = sprintf(_("[Studiengruppe: %s]"), $sem->getFullname()); } $this->redirect($this->url_for('messages/write', array('course_id' => $id, 'default_subject' => $subject, 'filter' => 'all', 'emailrequest' => 1))); }
/** * If a new user applies, an application note to all moderators and founders * of a studygroup will be automatically sent while calling this function. * The note contains the user's name and a direct link to the member page of the studygroup. * * @param string $sem_id id of a seminar / studygroup * @param strimg $user_id id of the applicant * * @return int number of recipients */ function applicationNotice($sem_id, $user_id) { $sem = new Seminar($sem_id); $dozenten = $sem->getMembers(); $tutors = $sem->getMembers('tutor'); $recipients = array(); $msging = new Messaging(); foreach (array_merge($dozenten, $tutors) as $uid => $user) { $recipients[] = $user['username']; } if (studip_strlen($sem->getName()) > 32) { //cut subject if to long $subject = sprintf(_("[Studiengruppe: %s...]"), studip_substr($sem->getName(), 0, 30)); } else { $subject = sprintf(_("[Studiengruppe: %s]"), $sem->getName()); } if (StudygroupModel::isInvited($user_id, $sem_id)) { $subject .= " " . _("Einladung akzeptiert"); $message = sprintf(_("%s hat die Einladung zur Studiengruppe %s akzeptiert. Klicken Sie auf den untenstehenden Link, um direkt zur Studiengruppe zu gelangen.\n\n [Direkt zur Studiengruppe]%s"), get_fullname($user_id), $sem->getName(), URLHelper::getlink($GLOBALS['ABSOLUTE_URI_STUDIP'] . "dispatch.php/course/studygroup/members/" . $sem->id, array('cid' => $sem->id))); } else { $subject .= " " . _("Neuer Mitgliedsantrag"); $message = sprintf(_("%s möchte der Studiengruppe %s beitreten. Klicken Sie auf den untenstehenden Link, um direkt zur Studiengruppe zu gelangen.\n\n [Direkt zur Studiengruppe]%s"), get_fullname($user_id), $sem->getName(), URLHelper::getlink($GLOBALS['ABSOLUTE_URI_STUDIP'] . "dispatch.php/course/studygroup/members/" . $sem->id, array('cid' => $sem->id))); } return $msging->insert_message($message, $recipients, "____%system%____", '', '', '', '', $subject); }