Пример #1
0
 /**
  * Update attachment record
  *
  * @return  void
  */
 public function saveItem($manifest, $blockId, $pub, $actor = 0, $elementId = 0, $aid = 0)
 {
     $aid = $aid ? $aid : Request::getInt('aid', 0);
     // Load classes
     $row = new \Components\Publications\Tables\Author($this->_parent->_db);
     $objO = new \Components\Projects\Tables\Owner($this->_parent->_db);
     // We need attachment record
     if (!$aid || !$row->load($aid) || $row->publication_version_id != $pub->version_id) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_CONTENT_ERROR_LOAD_AUTHOR'));
         return false;
     }
     // Instantiate a new registration object
     include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'registration.php';
     $xregistration = new \Components\Members\Models\Registration();
     // Get current owners
     $owners = $objO->getIds($pub->_project->get('id'), 'all', 1);
     $email = Request::getVar('email', '', 'post');
     $firstName = Request::getVar('firstName', '', 'post');
     $lastName = Request::getVar('lastName', '', 'post');
     $org = Request::getVar('organization', '', 'post');
     $credit = Request::getVar('credit', '', 'post');
     $sendInvite = 0;
     $code = \Components\Projects\Helpers\Html::generateCode();
     $uid = Request::getInt('uid', 0, 'post');
     $regex = '/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/';
     $email = preg_match($regex, $email) ? $email : '';
     if (!$firstName || !$lastName) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_ERROR_MISSING_REQUIRED'));
         return false;
     }
     $row->organization = $org;
     $row->firstName = $firstName;
     $row->lastName = $lastName;
     $row->name = $row->firstName . ' ' . $row->lastName;
     $row->credit = $credit;
     $row->modified_by = $actor;
     $row->modified = Date::toSql();
     // Check that profile exists
     if ($uid) {
         $profile = User::getInstance($uid);
         $uid = $profile->get('id') ? $uid : 0;
     }
     // Tying author to a user account?
     if ($uid && !$row->user_id) {
         // Do we have an owner with this user id?
         $owner = $objO->getOwnerId($pub->_project->get('id'), $uid);
         if ($owner) {
             // Update owner assoc
             $row->project_owner_id = $owner;
         } else {
             // Update associated project owner account
             if ($objO->load($row->project_owner_id) && !$objO->userid) {
                 $objO->userid = $uid;
                 $objO->status = 1;
                 $objO->store();
             }
         }
     }
     $row->user_id = $uid;
     if ($row->store()) {
         $this->set('_message', Lang::txt('Author record saved'));
         // Reflect the update in curation record
         $this->_parent->set('_update', 1);
     } else {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_AUTHORS_ERROR_SAVING_AUTHOR_INFO'));
         return false;
     }
     // Update project owner (invited)
     if ($email && !$row->user_id && $objO->load($row->project_owner_id)) {
         $invitee = $objO->checkInvited($pub->_project->get('id'), $email);
         // Do we have a registered user with this email?
         $user = $xregistration->getEmailId($email);
         if ($invitee && $invitee != $row->project_owner_id) {
             // Stop, must have owner record
         } elseif (in_array($user, $owners)) {
             // Stop, already in team
         } elseif ($email != $objO->invited_email) {
             $objO->invited_email = $email;
             $objO->invited_name = $row->name;
             $objO->userid = $row->user_id;
             $objO->invited_code = $code;
             $objO->store();
             $sendInvite = 1;
         }
     }
     // (Re)send email invitation
     if ($sendInvite && $email) {
         // Get project model
         $project = new \Components\Projects\Models\Project($pub->_project->get('id'));
         // Plugin params
         $plugin_params = array(0, $email, $code, 2, $project, 'com_projects');
         // Send invite
         $output = Event::trigger('projects.sendInviteEmail', $plugin_params);
         $result = json_decode($output[0]);
     }
     return true;
 }
Пример #2
0
 /**
  * Archive files
  *
  * @param   array  $items
  * @return  mixed  array or false
  */
 private function _archiveFiles($items)
 {
     if (!extension_loaded('zip')) {
         return false;
     }
     if (!$this->_path || !is_dir($this->_path)) {
         return false;
     }
     if (empty($items)) {
         return false;
     }
     $maxDownload = intval($this->params->get('maxDownload', 104857600));
     // Get temp directory
     $base_path = sys_get_temp_dir();
     $tarname = 'project_files_' . \Components\Projects\Helpers\Html::generateCode(6, 6, 0, 1, 1) . '.zip';
     $path = $this->subdir ? $this->_path . DS . $this->subdir : $this->_path;
     $combinedSize = 0;
     $tarpath = $base_path . DS . $tarname;
     $zip = new ZipArchive();
     if ($zip->open($tarpath, ZipArchive::OVERWRITE) === TRUE) {
         $i = 0;
         foreach ($items as $element) {
             foreach ($element as $type => $item) {
                 if ($type != 'file') {
                     continue;
                 } else {
                     $fpath = $path . DS . $item;
                     if (!is_file($fpath)) {
                         continue;
                     }
                     $combinedSize = $combinedSize + filesize($fpath);
                     // Check against maximum allowable size
                     if ($combinedSize > $maxDownload) {
                         $this->setError(Lang::txt('PLG_PROJECTS_FILES_ERROR_OVER_DOWNLOAD_LIMIT'));
                         return false;
                     }
                     $zip->addFile($fpath, basename($item));
                     $i++;
                 }
             }
         }
         $zip->close();
         if ($i == 0) {
             $this->setError(Lang::txt('PLG_PROJECTS_FILES_SERVER_ERROR'));
             return false;
         }
         $archive = array();
         $archive['path'] = $tarpath;
         $archive['name'] = $tarname;
         return $archive;
     }
     return false;
 }
Пример #3
0
 /**
  * Process parsed data
  *
  * @access public
  * @return string
  */
 public function processRecord($item, &$out)
 {
     // Create publication record
     if (!$item['publication']->store()) {
         return false;
     }
     $pid = $item['publication']->id;
     // Create version record
     $item['version']->publication_id = $pid;
     $item['version']->version_number = 1;
     $item['version']->created_by = $this->_uid;
     $item['version']->created = Date::toSql();
     $item['version']->secret = strtolower(\Components\Projects\Helpers\Html::generateCode(10, 10, 0, 1, 1));
     $item['version']->access = 0;
     $item['version']->main = 1;
     $item['version']->state = 3;
     if (!$item['version']->store()) {
         // Roll back
         $item['publication']->delete();
         return false;
     }
     $vid = $item['version']->id;
     // Build pub object
     $pub = new stdClass();
     $pub = $item['version'];
     $pub->id = $pid;
     $pub->version_id = $vid;
     // Build version object
     $version = new stdClass();
     $version->secret = $item['version']->secret;
     $version->id = $vid;
     $version->publication_id = $pid;
     // Create attachments records and attach files
     foreach ($item['files'] as $fileRecord) {
         $this->processFileData($fileRecord, $pub, $version);
     }
     // Create author records
     foreach ($item['authors'] as $authorRecord) {
         $this->processAuthorData($authorRecord['author'], $pid, $vid);
     }
     // Build tags string
     if ($item['tags']) {
         $tags = '';
         $i = 0;
         foreach ($item['tags'] as $tag) {
             $i++;
             $tags .= trim($tag);
             $tags .= $i == count($item['tags']) ? '' : ',';
         }
         // Add tags
         $tagsHelper = new \Components\Publications\Helpers\Tags($this->database);
         $tagsHelper->tag_object($this->_uid, $pid, $tags, 1);
     }
     // Display results
     $out .= '<p class="publication">#' . $pid . ': <a href="' . trim($this->site, DS) . '/publications/' . $pid . DS . '1" rel="external">' . $item['version']->title . ' v.' . $item['version']->version_label . '</a></p>';
     return true;
 }
Пример #4
0
 /**
  * Downloads file(s)
  *
  * @return  mixed
  */
 public function download()
 {
     $items = $this->getCollection();
     if (Request::getVar('render', 'download') == 'preview') {
         return $this->preview();
     }
     // Check items
     if (!$items || count($items) == 0) {
         $this->setError(Lang::txt('PLG_PROJECTS_FILES_ERROR_NO_FILES_TO_SHOW_HISTORY'));
         return;
     }
     if (count($items) > 1) {
         $archive = $items->compress();
         $result = $archive->serve('project_files_' . \Components\Projects\Helpers\Html::generateCode(6, 6, 0, 1, 1) . '.zip');
         // Delete the tmp file for serving
         $archive->delete();
     } else {
         $result = $items->first()->serve();
     }
     if (!$result) {
         // Should only get here on error
         throw new Exception(Lang::txt('PLG_PROJECTS_FILES_SERVER_ERROR'), 404);
     } else {
         exit;
     }
 }
Пример #5
0
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */
// No direct access
defined('_HZEXEC_') or die;
?>
	<?php 
if (count($this->items) > 0) {
    $parents = array();
    $openParents = array();
    $a = 1;
    // Get all parents
    foreach ($this->items as $item) {
        if ($item->get('type') == 'folder') {
            $tempId = strtolower(\Components\Projects\Helpers\Html::generateCode(5, 5, 0, 1, 1));
            $parents[$item->get('localPath')] = $tempId;
        }
        // Selected item?
        if (!empty($this->selected) && in_array($item->get('localPath'), $this->selected)) {
            if ($item->get('parents')) {
                foreach ($item->get('parents') as $i => $parent) {
                    $openParents[] = $parent;
                }
            }
        }
    }
    ?>
		<ul class="file-selector" id="file-selector">
			<?php 
    foreach ($this->items as $item) {
Пример #6
0
<?php 
if (count($this->items) > 0) {
    ?>
	<?php 
    $a = 1;
    ?>
	<?php 
    foreach ($this->items as $item) {
        $level = $item->getDirLevel($item->get('dirname'));
        if (Request::getInt('cid', false) !== false) {
            $level++;
        }
        $levelCss = 'level-' . $level;
        // Get element ID
        $liId = $item->get('type') == 'folder' ? 'dir-' . strtolower(\Components\Projects\Helpers\Html::generateCode(5, 5, 0, 1, 1)) : 'item-' . $a;
        // Assign parent classes (for collapsing)
        $parentCss = '';
        if ($parent = Request::getString('parent', false)) {
            $parentCss = ' parent-' . $parent;
        }
        $a++;
        // Is file already attached?
        $selected = !empty($this->selected) && in_array($item->get('localPath'), $this->selected) ? 1 : 0;
        // Is file type allowed?
        $allowed = $item->get('type') == 'file' && !empty($this->allowed) && !in_array($item->get('ext'), $this->allowed) ? ' notallowed' : ' allowed';
        $used = !empty($this->used) && in_array($item->get('localPath'), $this->used) ? true : false;
        // Do not allow files used in other elements
        $allowed = $used ? ' notallowed' : $allowed;
        // No selection for folders
        $allowed = $item->get('type') == 'folder' ? ' freeze' : $allowed;
Пример #7
0
 /**
  * Start/save a new version
  *
  * @return     string
  */
 public function newVersion()
 {
     // Incoming
     $pid = $this->_pid ? $this->_pid : Request::getInt('pid', 0);
     $ajax = Request::getInt('ajax', 0);
     $label = trim(Request::getVar('version_label', '', 'post'));
     // Check permission
     if (!$this->model->access('content')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
         return;
     }
     // Load default version
     $pub = new \Components\Publications\Models\Publication($pid, 'default');
     if (!$pub->exists()) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_NOT_FOUND'));
         $this->_task = '';
         return $this->browse();
     }
     // Make sure the publication belongs to the project
     if (!$pub->belongsToProject($this->model->get('id'))) {
         Notify::message(Lang::txt('PLG_PROJECTS_PUBLICATIONS_ERROR_PROJECT_ASSOC'), 'error', 'projects');
         App::redirect(Route::url($this->model->link('publications')));
         return;
     }
     // Set curation model
     $pub->setCuration();
     // Check if dev version is already there
     if ($pub->version->checkVersion($pid, 'dev')) {
         // Redirect
         App::redirect(Route::url($pub->link('editdev')));
         return;
     }
     // Can't start a new version if there is a finalized or submitted draft
     if ($pub->version->get('state') == 4 || $pub->version->get('state') == 5 || $pub->version->get('state') == 7) {
         // Determine redirect path
         App::redirect(Route::url($pub->link('editdefault')));
         return;
     }
     // Saving new version
     if ($this->_task == 'savenew') {
         $used_labels = $pub->version->getUsedLabels($pid, 'dev');
         if (!$label) {
             $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_VERSION_LABEL_NONE'));
         } elseif ($label && in_array($label, $used_labels)) {
             $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_VERSION_LABEL_USED'));
         } else {
             // Create new version
             $new = new \Components\Publications\Tables\Version($this->_database);
             // Copy from previous version
             $new->publication_id = $pub->get('publication_id');
             $new->title = $pub->get('title');
             $new->abstract = $pub->get('abstract');
             $new->description = $pub->get('description');
             $new->metadata = $pub->get('metadata');
             $new->release_notes = $pub->get('release_notes');
             $new->license_type = $pub->get('license_type');
             $new->license_text = $pub->get('license_text');
             $new->access = $pub->get('access');
             $new->created = Date::toSql();
             $new->created_by = $this->_uid;
             $new->modified = Date::toSql();
             $new->modified_by = $this->_uid;
             $new->state = 3;
             $new->main = 0;
             $new->version_label = $label;
             $new->version_number = $pub->versionCount() + 1;
             $new->secret = strtolower(\Components\Projects\Helpers\Html::generateCode(10, 10, 0, 1, 1));
             if ($new->store()) {
                 // Transfer data
                 $pub->_curationModel->transfer($pub, $pub->version, $new);
                 // Set response message
                 $this->set('_msg', Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_NEW_VERSION_STARTED'));
                 // Set activity message
                 $pubTitle = \Hubzero\Utility\String::truncate($new->title, 100);
                 $action = Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_ACTIVITY_STARTED_VERSION') . ' ' . $new->version_label . ' ';
                 $action .= Lang::txt('PLG_PROJECTS_PUBLICATIONS_OF_PUBLICATION') . ' "' . $pubTitle . '"';
                 $this->set('_activity', $action);
                 // Record action, notify team
                 $pub->set('version_number', $new->version_number);
                 $pub->set('version_label', $new->version_label);
                 $this->onAfterSave($pub);
             } else {
                 $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_ERROR_SAVING_NEW_VERSION'));
             }
         }
     } else {
         $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'newversion'));
         // Output HTML
         $view->option = $this->_option;
         $view->database = $this->_database;
         $view->project = $this->model;
         $view->uid = $this->_uid;
         $view->pid = $pid;
         $view->pub = $pub;
         $view->task = $this->_task;
         $view->config = $this->model->config();
         $view->pubconfig = $this->_pubconfig;
         $view->ajax = $ajax;
         $view->title = $this->_area['title'];
         // Get messages	and errors
         $view->msg = $this->_msg;
         if ($this->getError()) {
             $view->setError($this->getError());
         }
         return $view->loadTemplate();
     }
     // Pass success or error message
     if ($this->getError()) {
         \Notify::message($this->getError(), 'error', 'projects');
     } elseif (!empty($this->_msg)) {
         \Notify::message($this->_msg, 'success', 'projects');
     }
     // Redirect
     App::redirect(Route::url($pub->link('editdev')));
     return;
 }
Пример #8
0
?>
 Master Repository</span>
		</span>
	</li>

	<?php 
foreach ($this->connections as $connection) {
    ?>
		<?php 
    $imgRel = '/plugins/filesystem/' . $connection->provider->alias . '/assets/img/icon.png';
    ?>
		<?php 
    $img = is_file(PATH_APP . DS . $imgRel) ? '/app' . $imgRel : '/core' . $imgRel;
    ?>
		<?php 
    $id = 'dir-' . strtolower(\Components\Projects\Helpers\Html::generateCode(5, 5, 0, 1, 1));
    ?>
		<li class="type-folder collapsed connection" id="<?php 
    echo $id;
    ?>
" data-connection="<?php 
    echo $connection->id;
    ?>
" data-path=".">
			<span class="item-info"></span>
			<span class="item-wrap collapsor">
				<span class="collapsor-indicator">&nbsp;</span>
				<img src="<?php 
    echo $img;
    ?>
" alt="" />
Пример #9
0
 /**
  * Compile tex
  *
  * @access	public
  * @param	string		fullpath
  * @param	string		data
  * @param	string		textpath
  * @param	string		outputDir
  * @param	integer		getPath
  * @param	string		&tempBase
  * @return	string		compressed data
  */
 function compileTex($fullpath = '', $data = '', $texpath = '', $outputDir = '', $getPath = 0, &$tempBase = '')
 {
     if (!$texpath || !$data) {
         return false;
     }
     $cacheFolder = dirname($fullpath);
     $outputDir = $outputDir ? $outputDir : $this->_outputFolder;
     if (!$tempBase) {
         $filename = Html::takeOutExt(basename($fullpath));
         $texFile = $cacheFolder . DS . $filename . '__temp_' . Html::generateCode(6, 6, 0, 1, 1);
         $tempBase = basename($texFile);
     } else {
         $texFile = $cacheFolder . DS . $tempBase;
     }
     $pdf = $tempBase . '.pdf';
     // Remove previous compilation
     if (file_exists($outputDir . DS . $pdf)) {
         unlink($outputDir . DS . $pdf);
     }
     // Create temp tex copy
     $fp = fopen($texFile . '.tex', 'w');
     fwrite($fp, $data);
     fclose($fp);
     chdir($cacheFolder);
     $command = $texpath . DS . 'pdflatex -output-directory=' . $outputDir . ' -interaction=batchmode ' . escapeshellarg($texFile . '.tex');
     exec($command, $out);
     // Remove temp tex copy
     if (file_exists($texFile . '.tex')) {
         unlink($texFile . '.tex');
     }
     if (file_exists($texFile)) {
         unlink($texFile);
     }
     if (file_exists($outputDir . DS . $pdf)) {
         return $getPath ? basename($pdf) : file_get_contents($outputDir . DS . $pdf);
     }
     return false;
 }
Пример #10
0
 /**
  * Save member
  *
  * @return     void, redirect
  */
 protected function _save()
 {
     // Incoming
     $members = urldecode(trim(Request::getVar('newmember', '', 'post')));
     $groups = urldecode(trim(Request::getVar('newgroup', '')));
     $role = Request::getInt('role', 0);
     // Result collectors
     $m_added = 0;
     // count of individual members added
     $m_invited = 0;
     // count of individuals invited
     $g_added = 0;
     // count of members from new group
     $uids = array();
     // ids/emails of added people
     $names = array();
     // names/emails of added people
     $invalid = array();
     // collector for invalid names
     // Setup stage?
     $setup = $this->model->inSetup();
     // Get owner class
     $objO = $this->model->table('Owner');
     // Instantiate a new registration object
     include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'registration.php';
     $xregistration = new \Components\Members\Models\Registration();
     // Owner names not supplied
     if (!$members && !$groups) {
         if (!$setup) {
             $this->setError(Lang::txt('PLG_PROJECTS_TEAM_NO_NAMES_SUPPLIED'));
         } else {
             return;
         }
     } else {
         if ($members) {
             $newm = explode(',', $members);
             // Do we have new authors?
             if ($newm) {
                 for ($i = 0, $n = count($newm); $i < $n; $i++) {
                     $cid = strtolower(trim($newm[$i]));
                     $uid = 0;
                     if ($cid == '') {
                         continue;
                     }
                     $parts = preg_split("/[(]/", $cid);
                     if (count($parts) == 2) {
                         $name = $parts[0];
                         $uid = preg_replace('/[)]/', '', $parts[1]);
                     } elseif (intval($cid) && ($validUser = User::getInstance($cid))) {
                         $uid = $cid;
                     } else {
                         $regex = '/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/';
                         if (preg_match($regex, $cid)) {
                             // This is an email - check if user with the email exists
                             $uid = $xregistration->getEmailId($cid);
                             if (!$uid) {
                                 // Make sure we aren't inviting twice
                                 $invitee = $objO->checkInvited($this->model->get('id'), $cid);
                                 if (!$invitee) {
                                     // Generate invitation code
                                     $code = \Components\Projects\Helpers\Html::generateCode();
                                     // Add invitee record
                                     if ($objO->saveInvite($this->model->get('id'), $cid, $code, '', $role)) {
                                         $uids[] = $cid;
                                         $m_invited++;
                                         if (!$setup && $this->_config->get('messaging') == 1) {
                                             $this->sendInviteEmail(0, $cid, $code, $role);
                                         }
                                     }
                                 } elseif ($objO->load($invitee)) {
                                     // Previously deleted invite
                                     if ($objO->status == 2) {
                                         $objO->status = 0;
                                         $objO->role = $role;
                                         $uids[] = $cid;
                                         $objO->store();
                                         $m_invited++;
                                         if (!$setup && $this->_config->get('messaging') == 1) {
                                             $this->sendInviteEmail(0, $cid, $objO->invited_code, $objO->role);
                                         }
                                     }
                                 }
                             }
                         } else {
                             $invalid[] = $cid;
                         }
                     }
                     if (!$uid or !is_numeric($uid)) {
                         continue;
                     } else {
                         if (!User::getInstance($uid)) {
                             $invalid[] = $uid;
                             continue;
                         }
                     }
                     // Save new author
                     $native = $this->model->access('owner') ? 1 : 0;
                     if ($objO->saveOwners($this->model->get('id'), $this->_uid, $uid, 0, $role, $status = 1, $native)) {
                         $uids[] = $uid;
                     }
                 }
             }
         }
         if ($groups) {
             // Save new authors from group
             $g_added = $objO->saveOwners($this->model->get('id'), $this->_uid, 0, $groups, $role, $status = 1, $native = 0);
             if ($objO->getError()) {
                 $this->setError($objO->getError());
             }
             if ($g_added) {
                 $uids = array_merge($uids, $g_added);
             }
         }
     }
     // Did we add anyone new?
     $uids = array_unique($uids);
     if (count($uids) > 0) {
         $this->_msg = Lang::txt('PLG_PROJECTS_TEAM_SUCCESS_ADDED_OR_INVITED') . ' ' . count($uids) . ' ' . Lang::txt('PLG_PROJECTS_TEAM_NEW') . ' ' . Lang::txt('PLG_PROJECTS_TEAM_MEMBERS');
         if (count($invalid) > 0) {
             $this->_msg .= '<br />' . Lang::txt('PLG_PROJECTS_TEAM_MEMBERS_INVALID_NAMES');
         }
         if (!$setup) {
             $note = strtolower(Lang::txt('PLG_PROJECTS_TEAM_SUCCESS_ADDED_OR_INVITED')) . ' ';
             for ($i = 0; $i < count($uids); $i++) {
                 $uu = $uids[$i];
                 if ($uu && is_numeric($uu)) {
                     $xuser = User::getInstance($uids[$i]);
                     $note .= is_numeric($uids[$i]) && is_object($xuser) ? $xuser->get('name') : $uids[$i];
                 } else {
                     $note .= $uids[$i];
                 }
                 if ($i > 1) {
                     $left = count($uids) - 3;
                     if ($left) {
                         $note .= ' ' . Lang::txt('PLG_PROJECTS_TEAM_AND') . ' ' . $left . ' ' . Lang::txt('PLG_PROJECTS_TEAM_MORE') . ' ';
                         $note .= $left == 1 ? Lang::txt('PLG_PROJECTS_TEAM_ACTIVITY_PERSON') : Lang::txt('PLG_PROJECTS_TEAM_ACTIVITY_PERSONS');
                     }
                     break;
                 }
                 $note .= $i == count($uids) - 1 ? '' : ', ';
             }
             $note .= ' ' . Lang::txt('PLG_PROJECTS_TEAM_TO_PROJECT_TEAM');
             // Send out emails
             if ($this->_config->get('messaging') == 1) {
                 foreach ($uids as $user) {
                     $this->sendInviteEmail($user, '', '', $role);
                 }
             }
         }
         // Sync with system group
         $objO->sysGroup($this->model->get('alias'), $this->_config->get('group_prefix', 'pr-'));
     } elseif (count($invalid) > 0) {
         $this->setError(Lang::txt('PLG_PROJECTS_TEAM_MEMBERS_INVALID_NAMES') . '<br />' . Lang::txt('PLG_PROJECTS_TEAM_MEMBERS_INVALID_NAMES_EXPLAIN'));
     }
     // Pass error or success message
     if ($this->getError()) {
         \Notify::message($this->getError(), 'error', 'projects');
     } elseif (!empty($this->_msg)) {
         \Notify::message($this->_msg, 'success', 'projects');
     }
     $url = $setup ? Route::url($this->model->link('setup') . '&section=team') : Route::url($this->model->link('edit') . '&section=team');
     App::redirect($url);
     return;
 }
Пример #11
0
 /**
  * Expand archive
  *
  * @return  boolean
  */
 protected function _expand($file, $tmp_name, $target, $size, &$available, $params)
 {
     $engine = $this->_isTar($file) ? 'tar' : 'zip';
     $dirPath = isset($params['subdir']) ? $params['subdir'] : NULL;
     $tempPath = sys_get_temp_dir();
     $archive = $tempPath . DS . $file;
     $extractPath = $tempPath . DS . Helpers\Html::generateCode(7, 7, 0, 1, 0);
     if (isset($_GET['qqfile'])) {
         // Stream
         copy("php://input", $archive);
         $tmp_name = $archive;
     } elseif (!$tmp_name) {
         $this->setError(Lang::txt('COM_PROJECT_FILES_ERROR_UNZIP_FAILED'));
         return false;
     }
     if ($engine == 'tar') {
         // Create dir to extract into
         if (!is_dir($extractPath)) {
             Filesystem::makeDirectory($extractPath);
         }
         try {
             chdir($tempPath);
             exec('tar zxvf ' . $tmp_name . ' -C ' . $extractPath . ' 2>&1', $out);
         } catch (Exception $e) {
             $this->setError(Lang::txt('COM_PROJECT_FILES_ERROR_UNZIP_FAILED'));
             return false;
         }
     } else {
         $zip = new \ZipArchive();
         /***
         			Checks to see if the first entity is a file. If no '.' is found assume directory.
         			If no directory is found, create a unique one for the project to contain the files.
         			***/
         $topLevelDirectory = shell_exec("unzip -qql " . $tmp_name . " | head -n1 | tr -s ' ' | cut -d' ' -f5-");
         if (strpos($topLevelDirectory, '.') !== FALSE) {
             $extractPath = $extractPath . DS . 'archive-' . time() . DS;
             Filesystem::makeDirectory($extractPath);
         }
         if ($zip->open($tmp_name) === true) {
             $zip->extractTo($extractPath);
             $zip->close();
         } else {
             $this->setError(Lang::txt('COM_PROJECT_FILES_ERROR_UNZIP_FAILED'));
             return false;
         }
     }
     // Move extracted contents from temp to repo
     return $this->_addFromExtracted($extractPath, $file, $target, $params, $available);
 }
Пример #12
0
 /**
  * Expand archive
  *
  * @return  boolean
  */
 protected function _expand($file, $tmp_name, $target, $size, &$available, $params)
 {
     $engine = $this->_isTar($file) ? 'tar' : 'zip';
     $dirPath = isset($params['subdir']) ? $params['subdir'] : NULL;
     $tempPath = sys_get_temp_dir();
     $archive = $tempPath . DS . $file;
     $extractPath = $tempPath . DS . Helpers\Html::generateCode(7, 7, 0, 1, 0);
     if (isset($_GET['qqfile'])) {
         // Stream
         copy("php://input", $archive);
         $tmp_name = $archive;
     } elseif (!$tmp_name) {
         $this->setError(Lang::txt('COM_PROJECT_FILES_ERROR_UNZIP_FAILED'));
         return false;
     }
     if ($engine == 'tar') {
         // Create dir to extract into
         if (!is_dir($extractPath)) {
             Filesystem::makeDirectory($extractPath);
         }
         try {
             chdir($tempPath);
             exec('tar zxvf ' . $tmp_name . ' -C ' . $extractPath . ' 2>&1', $out);
         } catch (Exception $e) {
             $this->setError(Lang::txt('COM_PROJECT_FILES_ERROR_UNZIP_FAILED'));
             return false;
         }
     } else {
         $zip = new \ZipArchive();
         if ($zip->open($tmp_name) === true) {
             $zip->extractTo($extractPath);
             $zip->close();
         } else {
             $this->setError(Lang::txt('COM_PROJECT_FILES_ERROR_UNZIP_FAILED'));
             return false;
         }
     }
     // Move extracted contents from temp to repo
     return $this->_addFromExtracted($extractPath, $file, $target, $params, $available);
 }
Пример #13
0
 /**
  * Register stamp
  *
  * @param      integer 	$projectid		Project ID
  * @param      string 	$reference		Reference string to object (JSON)
  * @return     mixed False if error, Object on success
  */
 public function registerStamp($projectid = 0, $reference = '', $type = 'files', $listed = 0, $expires = NULL)
 {
     if (!$projectid || !$reference) {
         return false;
     }
     $now = Date::toSql();
     $obj = new self($this->_db);
     $obj->checkStamp($projectid, $reference, $type);
     // Load record
     if ($obj->id) {
         if ($obj->expires && $obj->expires != '0000-00-00 00:00:00' && $obj->expires < $now) {
             // Expired
             $obj->delete();
             return $this->registerStamp($projectid, $reference, $type, $listed, $expires);
         } else {
             if ($listed === NULL && $expires === NULL) {
                 return $obj->stamp;
             }
             // These values may be updated
             $obj->listed = $listed === NULL ? $obj->listed : $listed;
             $obj->expires = $expires === NULL ? $obj->expires : $expires;
             $obj->store();
             return $obj->stamp;
         }
     }
     // Make new entry
     $created = Date::toSql();
     $created_by = User::get('id');
     // Generate stamp
     require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'helpers' . DS . 'html.php';
     $stamp = \Components\Projects\Helpers\Html::generateCode(20, 20, 0, 1, 1);
     $query = "INSERT INTO {$this->_tbl} (stamp, projectid, listed, type, reference, expires, created, created_by)\n\t\t\t\t VALUES ('{$stamp}', '{$projectid}', '{$listed}', '{$type}', '{$reference}', '{$expires}' , '{$created}', '{$created_by}' )";
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     return $stamp;
 }
Пример #14
0
	<ul class="file-selector" id="file-selector">
<?php 
}
?>

<?php 
if (count($this->items) > 0) {
    ?>
	<?php 
    $a = 1;
    ?>
	<?php 
    foreach ($this->items as $item) {
        $levelCss = 'level-' . $item->getDirLevel();
        // Get element ID
        $liId = $item->isDir() ? 'dir-' . strtolower(\Components\Projects\Helpers\Html::generateCode(5, 5, 0, 1, 1)) : 'item-' . $a;
        // Assign parent classes (for collapsing)
        $parentCss = '';
        if ($parent = Request::getString('parent', false)) {
            $parentCss = ' parent-' . $parent;
        }
        $a++;
        // Is file already attached?
        $selected = !empty($this->selected) && in_array($item->getPath(), $this->selected) ? 1 : 0;
        // Is file type allowed?
        $allowed = $item->isFile() && !empty($this->allowed) && !in_array($item->getExtension(), $this->allowed) ? ' notallowed' : ' allowed';
        $used = !empty($this->used) && in_array($item->getPath(), $this->used) ? true : false;
        // Do not allow files used in other elements
        $allowed = $used ? ' notallowed' : $allowed;
        // No selection for folders
        $allowed = $item->isDir() ? ' freeze' : $allowed;
Пример #15
0
 /**
  * Create new version
  *
  * @param      object   $dev 				Version to duplicate
  * @param      integer  $state				New version status
  * @param      string   $secret 			New version secret
  * @param      integer  $version_number 	New version number
  * @param      integer   $main				Default?
  * @return     integer or False
  */
 public function createNewVersion($dev, $state = 1, $secret = '', $version_number = 1, $main = 1)
 {
     $new = new self($this->_db);
     $new = $dev;
     $new->id = 0;
     $new->rating = '0.0';
     $new->state = $state;
     $new->secret = $secret ? $secret : strtolower(\Components\Projects\Helpers\Html::generateCode(10, 10, 0, 1, 1));
     $new->version_number = $version_number;
     $new->main = $main;
     if ($new->store()) {
         return $new->id;
     } else {
         return false;
     }
 }