/** * List portals. * * @param Zend_Db_Table_Rowset_Abstract $portals * @return string */ public static function listResourceLibrary($docs) { $html = Functions_View::HTML_DEFAULT_EMPTY; if ($docs->count() == 0) { $html .= '<table class="table table-striped table-bordered">'; $html .= '<thead> <tr><th class="text-center">Sorry, No record(s) found!</th> </thead>'; $html .= '<tbody>'; return $html; exit; } if ($docs && $docs->count()) { $html .= '<table class="table table-striped table-bordered">'; $html .= '<thead> <tr > <th class="text-center"><div onclick="event.stopPropagation()"><a href="javascript:void(0)" onclick="setSortOrder(\'name\')">File Name</a></div></th> <th class="text-center"><div onclick="event.stopPropagation()">Kind</div></th> <th class="text-center"><div onclick="event.stopPropagation()"><a href="javascript:void(0)" onclick="setSortOrder(\'created_datetime\')">Date Added</a></div></th> <th class="text-center" style="width: 320px;"><div onclick="event.stopPropagation()">Tags</div></th> <th class="text-center"><div onclick="event.stopPropagation()">Download Link</div></th> </tr> </thead>'; $html .= '<tbody>'; foreach ($docs as $_doc) { $current_doc_boj = new Object_Document($_doc->id); //getting docuemnt tags $doc_tags = ""; $doc_tags = Repo_TagEntity::getInstance()->getEntityTags("document_asset", $_doc->id); $tagArray = array(); foreach ($doc_tags as $tag) { $tagArray[] = isset($tag->tag_name) ? $tag->tag_name : ""; } $tags_str = @implode(", ", $tagArray); $limit = 100; if (strlen($tags_str) > $limit) { $tags_str = substr($tags_str, 0, strrpos(substr($tags_str, 0, $limit), ' ')) . '...'; } //echo $tags_str; $html .= '<tr rel="' . $_doc->id . '" class="noClickThrough">'; $html .= '<td>' . $_doc->name . '</td>'; $html .= '<td>' . strtoupper(pathinfo($_doc->file_path, PATHINFO_EXTENSION)) . '</td>'; $html .= '<td>' . Functions_Common::formattedDay($_doc->created_datetime, parent::STD_DATE_FORMAT) . '</td>'; $html .= '<td>' . $tags_str . '</td>'; $html .= '<td><a class="btn btn-success" id="download" onclick="event.stopPropagation()" href="' . $current_doc_boj->getDownloadLink() . '" target="_blank">Download</a></td>'; $html .= '</tr>'; } $html .= '</tbody>'; $html .= '</table>'; } return $html; }
/** * Init function to set up form elements. * * @return void */ public function init() { $this->setAttrib('id', 'create-new-client-form'); $clientTypes = Repo_ClientType::getInstance()->getSelectArray(); $clientTree = Repo_Client::getInstance()->getClientTree(); // Build up the flat option array Functions_Common::$tempCache = array(); Functions_Common::flattenOptionTree($clientTree, Functions_Common::$tempCache, 'id', 'name', 'children', ''); $clientTreeOptions = array(' ' => ' ') + Functions_Common::$tempCache; // Name $this->addElement('text', 'client_name', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Client Name', 'required' => true)); // Parent $this->addElement('select', 'client_parent', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Parent Client', 'required' => false)); $this->getElement('client_parent')->addMultiOptions($clientTreeOptions); // Type $this->addElement('select', 'client_type', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Type', 'required' => false)); $this->getElement('client_type')->addMultiOptions($clientTypes); // ID $this->addElement('hidden', 'client_id', array('decorators' => $this->_buttonElementDecorator, 'required' => false)); }
/** * List portals. * * @param Zend_Db_Table_Rowset_Abstract $portals * @return string */ public static function listDocument($docs) { $html = Functions_View::HTML_DEFAULT_EMPTY; if ($docs && $docs->count()) { $html .= '<table class="table table-striped table-bordered">'; $html .= '<thead><tr><th class="text-center">Document</th><th class="text-center">Created</th>'; $html .= '<th class="text-center">Last Modified</th>'; $html .= '<th class="text-center">Description</th></tr></thead>'; $html .= '<tbody>'; foreach ($docs as $_doc) { $html .= '<tr rel="' . $_doc->id . '" class="noClickThrough">'; $html .= '<td>' . $_doc->name . '</td>'; $html .= '<td>' . Functions_Common::formattedDay($_doc->created_datetime, parent::STD_DATE_FORMAT) . '</td>'; $html .= '<td>' . Functions_Common::formattedDay($_doc->modified_datetime, parent::STD_DATE_FORMAT) . '</td>'; $html .= '<td>' . $_doc->description . '</td>'; $html .= '</tr>'; } $html .= '</tbody>'; $html .= '</table>'; } return $html; }
/** * List. * * @param Zend_Db_Table_Rowset_Abstract $portals * @return string */ public static function listAssets($assets) { $html = Functions_View::HTML_DEFAULT_EMPTY; if ($assets && $assets->count()) { $html .= '<table class="table table-striped table-bordered">'; $html .= '<thead><tr class="off"><th class="text-center sort" data-sort="name">Document</th><th class="text-center sort" data-sort="created">Created</th>'; $html .= '<th class="text-center sort" data-sort="modified">Last Modified</th>'; $html .= '<th class="text-center sort" data-sort="desc">Description</th></tr></thead>'; $html .= '<tbody>'; foreach ($assets as $_asset) { $_a = new Object_MediaAsset($_asset->id); $html .= '<tr rel="' . $_asset->id . '" class="noClickThrough">'; $html .= '<td class="selectMedia name" rel="' . $_a->getPublicLink() . '"><div>' . $_a->getPreviewHtml('300px') . '</div>' . $_asset->name . '</td>'; $html .= '<td class="created">' . Functions_Common::formattedDay($_asset->created_datetime, parent::STD_DATE_FORMAT) . '</td>'; $html .= '<td class="modified">' . Functions_Common::formattedDay($_asset->modified_datetime, parent::STD_DATE_FORMAT) . '</td>'; $html .= '<td class="desc">' . $_asset->description . '</td>'; $html .= '</tr>'; } $html .= '</tbody>'; $html .= '</table>'; } return $html; }
/** * Generate a complete link URL for a resource. * * @param string $resourceType * @param string $resourceExternalLinkHash * @return string */ public function getLink($resourceType, $resourceExternalLinkHash, $type = 'url') { return Functions_Common::hostUrl() . '/' . $type . '/' . $resourceType . '/' . $resourceExternalLinkHash; }
/** * Generate a page screenshot. * * @param integer $pageId * @return array | false */ protected function _generateScreenshot($pageId) { $page = new Object_Page($pageId); if (!$page->getId()) { return false; } if (!$page->getPreviewLink()) { return false; } $url = $page->getPreviewLink(); if (!$page->cloud_file_container) { $url = Functions_Common::hostUrl() . $url; } $capturedImage = $this->getAdapter()->setWorkingDir($page->getStaticContentFolder())->capture($url, self::$defaultImageName, array('delay' => self::$defaultDelay)); return $capturedImage; }
/** * List one level of threads. Used as a recursive function. * * @param array $threads * @param integer $parentId * @return string */ public static function threadList($threads, $parentId = false) { $html = Functions_View::HTML_DEFAULT_EMPTY; $childHtml = ''; if ($threads && is_array($threads)) { foreach ($threads as $_thread) { if ((int) $_thread['parent_id'] == (int) $parentId) { $html .= '<li class="list-group-item">'; $html .= '<h6><div class="pull-right">'; $html .= '</div><!--<input class="comment-approved" type="checkbox" rel="' . $_thread['id'] . '" ' . ($_thread['is_approved'] ? ' checked="checked"' : '') . '/>--> '; $html .= $_thread['firstname'] . ' ' . $_thread['surname'] . ' says on '; $html .= '<span class="small">' . Functions_Common::formattedDay($_thread['post_datetime'], parent::STD_DATE_FORMAT) . '</span></h6>'; $html .= '<div class="row thread-update-' . $_thread['id'] . '-body">' . $_thread['body']; $html .= '</div>'; $html .= '<div class="row thread-update-' . $_thread['id'] . '-action" style="display: none"> <div class="btn-group"><button class="btn btn-primary edit-thread" rel="' . $_thread['id'] . '">Update Comment</button><button class="btn btn-warning edit-thread-cancel" rel="' . $_thread['id'] . '">Cancel</button></div> </div>'; $html .= '<div>'; $html .= '<a class="reply-handle" href="#" rel="thread-reply-' . $_thread['id'] . '">Reply</a>'; $html .= $_thread['user_id'] == Auth_Wrapper_User::getUserId() ? ' | <a class="edit-handle" href="#" rel="thread-update-' . $_thread['id'] . '">Edit</a>' : ''; $html .= $_thread['user_id'] == Auth_Wrapper_User::getUserId() ? ' | <a class="delete-handle" href="#" rel="' . $_thread['id'] . '">Delete</a>' : ''; $html .= '</div>'; // Edit /*$html .= '<div class="row thread-update-' . $_thread['id'] . '" . style="display: none"> <div class="col-md-8"> <textarea rows="3" width="100%" class="form-control edit-thread-content">' . $_thread['body'] . '</textarea> </div> <div class="col-md-4"> <div class="btn-group"><button class="btn btn-primary edit-thread" rel="' . $_thread['id'] . '">Update Comment</button><button class="btn btn-warning edit-thread-cancel" rel="' . $_thread['id'] . '">Cancel</button></div> </div> </div>';*/ // Reply $html .= '<div class="row thread-reply-' . $_thread['id'] . '" . style="display: none"> <div class="col-md-8"> <textarea rows="3" width="100%" class="form-control new-thread"></textarea> </div> <div class="col-md-4"> <div class="btn-group"><button class="btn btn-primary add-new-thread" rel="' . $_thread['id'] . '">Reply</button><button class="btn btn-warning add-new-thread-cancel" rel="' . $_thread['id'] . '">Cancel</button></div> </div> </div>'; $childHtml = self::threadList($threads, $_thread['id']); if (!empty($childHtml)) { $html .= '<div> </div><ul>' . $childHtml . '</ul></li>'; } else { $html .= '</li>'; } } } } return $html; }
/** * Send an email to presenter himself. * * @param integer $sessionId * return boolean */ public function sendSelfEmail($sessionId) { $session = new Object_PromoteSession($sessionId); if (!$session->getId()) { return false; } $userEmail = Zend_Auth::getInstance()->getIdentity()->email; $t = Zend_Registry::getInstance()->translate; $emailBody = $t->_('promote-self-email-body'); $emailBody = str_replace(array('{promoteSessionPresenterLink}'), array(Functions_Common::hostUrl() . '/promote/presenter/session/' . $session->ukey), $emailBody); $emailSubject = $t->_('promote-self-email-subject'); $emailSubject = str_replace(array('{promoteSessionSubject}'), array($this->getValue('subject') . ' ' . date('n/j/y G:i T')), $emailSubject); $emailAgent = new Mail_Mail(); $emailAgent->setBody($emailBody)->setSubject($emailSubject)->setTo($userEmail); try { $emailAgent->send(); } catch (Exception $e) { // Ignore for now } return true; }
/** * Generate a page screenshot. * * @param integer $pageId * @param array $tokens * @return array | false */ protected function _generate($templateId, $tokens = array()) { if (!$tokens) { $tokens = array(); } $pdfName = md5($templateId . '_' . serialize($tokens)); $template = new Object_PdfTemplate($templateId); if (!$template->getId()) { return false; } if (!$template->getPreviewLink()) { return false; } // Generate the GET URL with tokens $tokenUrl = 'tokens=' . urlencode(Zend_Json::encode($tokens)); $captureImage = $this->getAdapter()->setWorkingDir($template->getFolderPath())->capture(Functions_Common::hostUrl() . $template->getPreviewLink() . '?' . $tokenUrl, $pdfName . '.pdf', array('delay' => self::$defaultDelay, 'isPdf' => true)); // Turn this into a pdf /*$pdf = new Zend_Pdf(); $pdfImage = Zend_Pdf_Image::imageWithPath($captureImage); $pdfPage = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE); $pdfPage->drawImage($pdfImage, 20, 20, $pdfPage->getWidth() - 20, $pdfPage->getHeight() - 20); $pdf->pages[] = $pdfPage; $path = $this->_rootPath . DS . $pdfName . '.pdf'; $pdf->save($path);*/ return $pdfName; }
/** * Create an ics file. * */ public function createIcsFile($session, $key) { $zone = date_default_timezone_set('UTC'); $timestamp = DateTime::createFromFormat('Y-m-d H:i:s', $session->created_datetime); $start = DateTime::createFromFormat('Y-m-d H:i:s', date('Y-m-d H:i:s', substr($session->start_datetime, 0, 10))); $end = DateTime::createFromFormat('Y-m-d H:i:s', date('Y-m-d H:i:s', substr($session->start_datetime, 0, 10) + 30 * 60)); $sessionLink = Functions_Common::hostUrl() . '/promote/viewer/key/' . $key; $sessionLinkContent = ' Join the meeting: ' . Functions_Common::hostUrl() . '/promote/viewer/key/' . $key; // Start part $fileContent = <<<ICS BEGIN:VCALENDAR CALSCALE:GREGORIAN VERSION:2.0 PRODID:-//Lifelearn//Meetings//EN BEGIN:VEVENT UID:{$key} DTSTAMP:{$timestamp->format('Y')}{$timestamp->format('m')}{$timestamp->format('d')}T{$timestamp->format('H')}{$timestamp->format('i')}{$timestamp->format('s')}Z DTSTART:{$start->format('Y')}{$start->format('m')}{$start->format('d')}T{$start->format('H')}{$start->format('i')}{$start->format('s')}Z DTEND:{$end->format('Y')}{$end->format('m')}{$end->format('d')}T{$end->format('H')}{$end->format('i')}{$end->format('s')}Z SUMMARY:{$session->subject} SEQUENCE:{$session->update_sequence} ICS; // Add organizer $presenter = new Object_User($session->user_id); $fileContent .= "\n" . 'ORGANIZER;CN=' . $presenter->firstname . ' ' . $presenter->surname . ':MAILTO:' . $presenter->email . "\n"; // Add attendees $contacts = Repo_PromoteSessionContact::getInstance()->getSessionContacts($session->id); foreach ($contacts as $_contact) { $fileContent .= 'ATTENDEE;CN=' . $_contact->firstname . ' ' . $_contact->surname . ':MAILTO:' . $_contact->email . "\n"; } // End part $fileContent .= <<<ICS DESCRIPTION: {$session->invite_message}{$sessionLinkContent} URL:{$sessionLink} BEGIN:VALARM TRIGGER:-PT15M ACTION:DISPLAY DESCRIPTION:Reminder END:VALARM END:VEVENT END:VCALENDAR ICS; return $fileContent; }
/** * Reset password request with email address. * * @return boolean */ public function resetPasswordRequest($extra_parameters = null) { // Generate new key $newKey = md5($this->getId() . '_' . $this->email . '_' . time()); $this->password_reset_key = $newKey; $this->save(); $baseResetURL = Functions_Common::hostUrl() . '/login/reset-password/key/'; $sendingEntity = ""; //Customize for students if necessary if (!is_null($extra_parameters)) { if ($extra_parameters->getValue('studentData')) { $urlParams = urldecode($extra_parameters->getValue('studentData')); $urlParams = json_decode($urlParams); $resetSender = $urlParams->resetSender; $resetURL = $urlParams->resetUrl; $baseResetURL = "http://" . $resetURL . "?reset-password="******" for " . $resetSender; } } // Send out email $t = Zend_Registry::getInstance()->translate; $emailBody = $t->_('forgot-password-email-body'); $emailBody = str_replace(array('{resetPasswordLink}'), array($baseResetURL . $this->password_reset_key), $emailBody); $emailSubject = $t->_('forgot-password-email-subject') . $sendingEntity; $emailAgent = new Mail_Mail(); $emailAgent->setBody($emailBody)->setSubject($emailSubject)->setTo($this->email); try { $emailAgent->send(); } catch (Exception $e) { return false; } return true; }
/** * Get list of entities for an array of tag ids for a certain type. * * @param array $tagIds * @param string $entityType * * @return array */ public function getEntitiesForTags($tagIds, $entityType) { if (empty($tagIds)) { return array(); } $dbTable = $this->getFetchTable(); $select = $dbTable->select()->setIntegrityCheck(false)->from(array('te' => 'tag_entity'), array('id' => 'te.entity_id')); $select->where('te.entity_type = ?', $entityType); $tagIds = Functions_Common::arrayOfNumbers($tagIds); $select->where('te.tag_id IN (' . implode(',', $tagIds) . ')'); $entities = $dbTable->fetchAll($select); $entityIds = array(); foreach ($entities as $_e) { $entityIds[] = $_e->id; } return $entityIds; }