コード例 #1
0
 /**
  * @return array
  * @version 2015062901
  * @since 2015062901
  */
 private function getAllPhoneNumbers()
 {
     $numbers = array();
     $contactNumbers = $this->addressbookDAO->getPhonenumbersOfAllContacts();
     $users = $this->userDAO->getAllUsers();
     foreach ($contactNumbers as $number) {
         $numbers[] = $number;
     }
     foreach ($users as $user) {
         if ($user->getRecipientNumber() != NULL && $user->getRecipientNumber()->getPhoneNumber() != NULL) {
             $numbers[] = $user->getRecipientNumber()->getPhoneNumber();
         }
     }
     return array_unique($numbers);
 }
コード例 #2
0
 /**
  * Updates a contact's details in the DB according to the
  * values passed via AJAX
  * @global object $USER Moodle user object (session persistent)
  * @param int $addressbookId ID of addressbook to update
  * @param int $contactId ID of contact to update
  * @param string $contactFirstName Contact's first name
  * @param string $contactLastName Contact's last name
  * @param string $contactCompany Contact's employer
  * @param string $contactPhoneNumber Contact's phone number
  * @return string JSON-encoded response to request
  * @throws MoodletxtAJAXException
  * @version 2012061801
  * @since 2012090501
  */
 private function updateContact($addressbookId, $contactId, $contactFirstName, $contactLastName, $contactCompany, $contactPhoneNumber)
 {
     global $USER;
     // Check that user owns DB
     if (!$this->addressbookDAO->checkAddressbookOwnership($addressbookId, $USER->id)) {
         throw new MoodletxtAJAXException(get_string('errorbooknotowned', 'block_moodletxt'), MoodletxtAJAXException::$ERROR_NOT_ADDRESSBOOK_OWNER, null, false);
     }
     // Get record from DB and update it
     try {
         $contact = $this->addressbookDAO->getAddressbookContactById($addressbookId, $contactId);
         $contact->setFirstName($contactFirstName);
         $contact->setLastName($contactLastName);
         $contact->setCompanyName($contactCompany);
         $contact->setRecipientNumber(new MoodletxtPhoneNumber($contactPhoneNumber));
         $this->addressbookDAO->saveContact($contact);
     } catch (InvalidArgumentException $ex) {
         throw new MoodletxtAJAXException(get_string('errorbadcontactid', 'block_moodletxt'), MoodletxtAJAXException::$ERROR_CODE_BAD_CONTACT_ID, null, false);
     }
     return $this->buildResponse($contact);
 }
コード例 #3
0
ファイル: send.php プロジェクト: educacionbe/campus
require_once $CFG->dirroot . '/blocks/moodletxt/connect/MoodletxtOutboundControllerFactory.php';
$courseId = required_param('course', PARAM_INT);
$instanceId = required_param('instance', PARAM_INT);
$replyType = optional_param('replyType', '', PARAM_ALPHA);
$replyValue = optional_param('replyValue', '', PARAM_RAW_TRIMMED);
if ($replyType == 'additional' && !MoodletxtPhoneNumber::validatePhoneNumber($replyValue)) {
    $replyType = '';
    $replyValue = '';
}
require_login($courseId, false);
$blockcontext = context_block::instance($instanceId);
require_capability('block/moodletxt:sendmessages', $blockcontext, $USER->id);
// OK, so you're legit. Let's load DAOs and required DB data
$templateDAO = new MoodletxtTemplatesDAO();
$accountDAO = new TxttoolsAccountDAO();
$addressbookDAO = new MoodletxtAddressbookDAO();
$userDAO = new MoodletxtMoodleUserDAO();
$messageDAO = new TxttoolsSentMessageDAO();
$statsDAO = new MoodletxtUserStatsDAO();
$course = $DB->get_record('course', array('id' => $courseId));
$notifications = '';
// Set up the page for rendering
$PAGE->set_url('/blocks/moodletxt/send.php');
$PAGE->set_title(get_string('titlesend', 'block_moodletxt') . ' ' . $course->fullname);
$PAGE->set_heading(get_string('headersend', 'block_moodletxt'));
$PAGE->set_pagelayout('incourse');
$PAGE->set_button('');
// Clear editing button
$PAGE->navbar->add(get_string('navmoodletxt', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt');
$PAGE->navbar->add(get_string('navsent', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt');
$PAGE->requires->strings_for_js(array('errorlabel', 'errornonumber', 'errornofirstname', 'errornolastname', 'errornorecipientsselected', 'errornomessage'), 'block_moodletxt');
コード例 #4
0
 * @since 2012092401
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/blocks/moodletxt/dao/MoodletxtAddressbookDAO.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/MoodletxtGroupAddForm.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/MoodletxtGroupEditForm.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/MoodletxtGroupDeleteForm.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/renderers/QuickFormRendererWithSlides.php';
$courseId = required_param('course', PARAM_INT);
$instanceId = required_param('instance', PARAM_INT);
$addressbookId = required_param('addressbook', PARAM_INT);
require_login($courseId, false);
$blockcontext = context_block::instance($instanceId);
require_capability('block/moodletxt:addressbooks', $blockcontext, $USER->id);
// OK, so you're legit. Let's load DAOs
$addressbookDAO = new MoodletxtAddressbookDAO();
if (!$addressbookDAO->checkAddressbookOwnership($addressbookId, $USER->id)) {
    print_error('errorbadbookid', 'block_moodletxt');
}
$addressbook = $addressbookDAO->getAddressbookById($addressbookId, $USER->id);
// SETUP PAGE
$PAGE->set_url('/blocks/moodletxt/addressbook_groups.php');
$PAGE->set_title(get_string('titlegroupsmanage', 'block_moodletxt') . ' "' . $addressbook->getName() . '"');
$PAGE->set_heading(get_string('headergroupsmanage', 'block_moodletxt'));
$PAGE->set_pagelayout('incourse');
$PAGE->set_button('');
// Clear editing button
$addressbookNav = new moodle_url('/blocks/moodletxt/addressbooks.php', array('course' => $courseId, 'instance' => $instanceId));
$addressbookEditNav = new moodle_url('/blocks/moodletxt/addressbook_view.php', array('course' => $courseId, 'instance' => $instanceId, 'addressbook' => $addressbook->getId()));
$PAGE->navbar->add(get_string('navmoodletxt', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt');
$PAGE->navbar->add(get_string('navaddressbooks', 'block_moodletxt'), $addressbookNav, navigation_node::TYPE_CUSTOM, 'moodletxt');
コード例 #5
0
ファイル: addressbooks.php プロジェクト: educacionbe/campus
 * @author Greg J Preece <*****@*****.**>
 * @copyright Copyright &copy; 2014 Blackboard Connect. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public Licence v3 (See code header for additional terms)
 * @version 2013070201
 * @since 2012071701
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/blocks/moodletxt/dao/MoodletxtAddressbookDAO.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/MoodletxtAddressbookManagementForm.php';
$courseId = required_param('course', PARAM_INT);
$instanceId = required_param('instance', PARAM_INT);
require_login($courseId, false);
$blockcontext = context_block::instance($instanceId);
require_capability('block/moodletxt:addressbooks', $blockcontext, $USER->id);
// OK, so you're legit. Let's load DAOs
$addressbookDAO = new MoodletxtAddressbookDAO();
$addressbookList = $addressbookDAO->getAddressbooksForUser($USER->id);
$PAGE->set_url('/blocks/moodletxt/addressbooks.php');
$PAGE->set_title(get_string('titleaddressbooks', 'block_moodletxt') . ' ' . $USER->lastname . ', ' . $USER->firstname);
$PAGE->set_heading(get_string('headeraddressbooks', 'block_moodletxt'));
$PAGE->set_pagelayout('incourse');
$PAGE->set_button('');
// Clear editing button
$PAGE->navbar->add(get_string('navmoodletxt', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt');
$PAGE->navbar->add(get_string('navaddressbooks', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt');
$output = $PAGE->get_renderer('block_moodletxt');
// Builds the form object according to which addressbooks
// are available to the user, and whether they can create
// global addressbooks
$customFormData = array('existingAddressbooks' => array(0 => ''));
$initialFormData = array('course' => $courseId, 'instance' => $instanceId);
コード例 #6
0
 /**
  * Saves inbound messages to the database
  * @global moodle_database $DB Moodle database manager
  * @param MoodletxtInboundMessage[] $messages Messages to save
  * @version 2013102301
  * @since 2012041701
  */
 public function saveInboundMessages(array $messages)
 {
     global $DB;
     // Needed to do addressbook/user lookups
     $addressbookDAO = new MoodletxtAddressbookDAO();
     foreach ($messages as $message) {
         if (!$message instanceof MoodletxtInboundMessage) {
             continue;
         }
         // Look for associated users or contacts
         if ($message->hasOwner()) {
             $addressbookOwners = array($message->getOwner()->getId());
         } else {
             $addressbookOwners = $message->getDestinationUserIds();
         }
         $associatedSources = $addressbookDAO->associateNumberWithRecipient($message->getSourceNumber(), $addressbookOwners);
         if (isset($associatedSources['user'])) {
             $message->setAssociatedSource($associatedSources['user']);
         } else {
             if (isset($associatedSources['addressbook'])) {
                 $message->setAssociatedSource($associatedSources['addressbook']);
             } else {
                 $message->setSourceFirstName(get_string('fragunknown', 'block_moodletxt'));
                 $message->setSourceLastName(get_string('fragunknown', 'block_moodletxt'));
             }
         }
         // Tear-down to basic object
         $rawMessages = $this->convertBeanToStandardClasses($message);
         foreach ($rawMessages as $rawMessage) {
             // Insert or update
             if (isset($rawMessage->id)) {
                 $DB->update_record('block_moodletxt_inbox', $rawMessage);
             } else {
                 $rawMessage->id = $DB->insert_record('block_moodletxt_inbox', $rawMessage);
             }
             // If an associated source was found, we need to make a link
             $associatedSource = $message->getSource();
             if ($associatedSource instanceof MoodletxtBiteSizedUser) {
                 // If there was already a link, nuke it
                 $DB->delete_records('block_moodletxt_in_u', array('receivedmessage' => $rawMessage->id));
                 $userLink = new object();
                 $userLink->userid = $associatedSource->getId();
                 $userLink->receivedmessage = $rawMessage->id;
                 $DB->insert_record('block_moodletxt_in_u', $userLink);
             } else {
                 if ($associatedSource instanceof MoodletxtAddressbookRecipient) {
                     // If there was already a link, nuke it
                     $DB->delete_records('block_moodletxt_in_ab', array('receivedmessage' => $rawMessage->id));
                     $contactLink = new object();
                     $contactLink->contact = $associatedSource->getContactId();
                     $contactLink->receivedmessage = $rawMessage->id;
                     $DB->insert_record('block_moodletxt_in_ab', $contactLink);
                 }
             }
         }
     }
 }
コード例 #7
0
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public Licence v3 (See code header for additional terms)
 * @version 2014071401
 * @since 2012090401
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/blocks/moodletxt/dao/MoodletxtAddressbookDAO.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/MoodletxtContactAddForm.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/renderers/QuickFormRendererWithSlides.php';
$courseId = required_param('course', PARAM_INT);
$instanceId = required_param('instance', PARAM_INT);
$addressbookId = required_param('addressbook', PARAM_INT);
require_login($courseId, false);
$blockcontext = context_block::instance($instanceId);
require_capability('block/moodletxt:addressbooks', $blockcontext, $USER->id);
// OK, so you're legit. Let's load DAOs
$addressbookDAO = new MoodletxtAddressbookDAO();
if (!$addressbookDAO->checkAddressbookOwnership($addressbookId, $USER->id)) {
    print_error('errorbadbookid', 'block_moodletxt');
}
$addressbook = $addressbookDAO->getAddressbookById($addressbookId, $USER->id);
// SETUP PAGE
$PAGE->set_url('/blocks/moodletxt/addressbook_contact_add.php');
$PAGE->set_title(get_string('titlecontactadd', 'block_moodletxt') . ' "' . $addressbook->getName() . '"');
$PAGE->set_heading(get_string('headercontactadd', 'block_moodletxt'));
$PAGE->set_pagelayout('incourse');
$PAGE->set_button('');
// Clear editing button
$addressbookNav = new moodle_url('/blocks/moodletxt/addressbooks.php', array('course' => $courseId, 'instance' => $instanceId));
$addressbookEditNav = new moodle_url('/blocks/moodletxt/addressbook_view.php', array('course' => $courseId, 'instance' => $instanceId, 'addressbook' => $addressbook->getId()));
$PAGE->navbar->add(get_string('navmoodletxt', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt');
$PAGE->navbar->add(get_string('navaddressbooks', 'block_moodletxt'), $addressbookNav, navigation_node::TYPE_CUSTOM, 'moodletxt');
コード例 #8
0
require_once '../../config.php';
require_once $CFG->libdir . '/tablelib.php';
require_once $CFG->dirroot . '/blocks/moodletxt/dao/MoodletxtAddressbookDAO.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/MoodletxtAddressbookUpdateForm.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/MoodletxtAddressbookControlForm.php';
require_once $CFG->dirroot . '/blocks/moodletxt/forms/renderers/InlineFormRenderer.php';
$courseId = required_param('course', PARAM_INT);
$instanceId = required_param('instance', PARAM_INT);
$addressbookId = required_param('addressbook', PARAM_INT);
$download = optional_param('download', '', PARAM_ALPHA);
$CONTACTS_PER_PAGE = 25;
require_login($courseId, false);
$blockcontext = context_block::instance($instanceId);
require_capability('block/moodletxt:addressbooks', $blockcontext, $USER->id);
// OK, so you're legit. Let's load DAOs
$addressbookDAO = new MoodletxtAddressbookDAO();
if (!$addressbookDAO->checkAddressbookOwnership($addressbookId, $USER->id)) {
    print_error('errorbadbookid', 'block_moodletxt');
}
$addressbook = $addressbookDAO->getAddressbookById($addressbookId, $USER->id);
// SETUP PAGE
$pageParams = '?course=' . $courseId . '&instance=' . $instanceId . '&addressbook=' . $addressbookId;
$PAGE->set_url('/blocks/moodletxt/addressbook_view.php');
$PAGE->set_title(get_string('titleaddressbookedit', 'block_moodletxt'));
$PAGE->set_heading(get_string('headeraddressbookedit', 'block_moodletxt'));
$PAGE->set_pagelayout('incourse');
$PAGE->set_button('');
// Clear editing button
$addressbookNav = new moodle_url('/blocks/moodletxt/addressbooks.php', array('course' => $courseId, 'instance' => $instanceId));
$PAGE->navbar->add(get_string('navmoodletxt', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt');
$PAGE->navbar->add(get_string('navaddressbooks', 'block_moodletxt'), $addressbookNav, navigation_node::TYPE_CUSTOM, 'moodletxt');