Hi Ryan,
Not that I can see, the only thing i did, was adding 2 templates, it has to be in one of these templates then I guess.
- one template is a private login template:
<?php
if($input->post->login_submit) {
// process submitted login form
$name = $sanitizer->username($input->post->lblUsername);
$pass = $input->post->lblPassword;
if($session->login($name, $pass)) $session->redirect("./");
else echo '<p class="ui-state-error-text">Login failed, please try again.</p>';
}
if($user->isLoggedin() && $user->hasRole("distributors")) {
$categories = $pages->get("/private/")->children();
if (count($categories)>0) {
?>
<ul class="tabs">
<?php
foreach($categories as $category) {
echo "<li><a href='#{$category->id}'>{$category->title}</a></li>";
}
?>
<li><a href='#upload32654981'>Upload new file</a></li>
</ul>
<div class="tab_container">
<?php
foreach($categories as $category) {
$product_arr = array();
echo "<div id='{$category->id}' class='tab_content'>";
$children = $category->children();
if (count($children)>0) {
foreach($children as $products) {
foreach($products->related_products as $product) {
$product_arr[] = $product->title;
}
}
?>
<?php
$product_arr = array_unique($product_arr);
foreach ($product_arr as $value) {
echo "<h2 class='acc_trigger'><a href='#'>» $value</a></h2>";
?>
<div class="acc_container">
<div class="block">
<?php
foreach($children as $child) {
$productchild_arr = array();
foreach($child->related_products as $productchild) {
$productchild_arr[] = $productchild->title;
}
if (in_array($value, $productchild_arr)) {
if ($child->template == 'client_images') {
foreach($child->client_images as $image) {
$thumb = $image->height(200);
echo "<a href='{$image->url}' target='_blank'><img src='{$thumb->url}' alt='{$thumb->description}' title='{$thumb->description}' width='{$thumb->width()}' height='{$thumb->height()}' /></a>";
}
} else {
?>
<table>
<?php foreach($child->client_documents as $doc) { ?>
<tr>
<td><a href='<?=$doc->url?>' target='_blank'><img src='<?php echo $config->urls->templates?>img/<?=$doc->ext?>_icon.png' alt='<?=$doc->get('description|name')?>' title='<?=$doc->get('description|name')?>' width='50' height='50'/></a></td>
<td><?=$doc->name?><br/><?=$doc->description?></td>
<td><?=strtoupper($doc->filesizeStr)?></td>
</tr>
<?php } ?>
</table>
<?php
}
}
}
?>
</div>
</div>
<?php
}
}
echo "</div>";
}
?>
<div id='upload32654981' class='tab_content'>
<?php
$fileextensions = $page->fields->get("client_upload")->extensions;
if($input->post->upload_submit) {
$uploadtab = TRUE;
$page->setOutputFormatting(false);
// instantiate the class and give it the name of the HTML field
$u = new WireUpload('lblUpload');
$u->setMaxFiles(1);
$u->setOverwrite(false);
$u->setDestinationPath($page->client_upload->path);
$valid_ext = explode(" ", $fileextensions);
$u->setValidExtensions($valid_ext);
// execute() returns an array, so we'll foreach() it even though only 1 file
$exec_arr = $u->execute();
if(empty($exec_arr) || !count($exec_arr)) {
if(empty($notices) || !count($notices)) {
echo "<p class='ui-state-error-text'>Error: Choose a file to upload!</p>";
} else {
foreach($notices as $notice) {
if($notice instanceof NoticeError) {
echo "<p class='ui-state-error-text'>Error: {$notice->text}</p>";
}
}
}
} else {
foreach($exec_arr as $filename) $page->client_upload->add($filename);
$lastfile = $page->client_upload->last();
$lastfile->description = implode(",", $input->post->lblProducts);
$page->save();
echo "<p>You file has been uploaded successfully!</p>";
}
} else {
$uploadtab = FALSE;
?>
<form action='./' method='post' class="upload_form" enctype="multipart/form-data">
<ul class='Inputfields'>
<li class='InputfieldText Inputfield_lblUpload ui-widget' id='wrap_Inputfield_lblUpload'>
<div class='ui-widget-content'>
<p class="description InputfieldFileValidExtensions"><?php echo $fileextensions; ?></p>
<p><input id="Inputfield_lblUpload" class="required InputfieldMaxWidth" name="lblUpload" type="file" maxlength="255" /></p>
</div>
</li>
<li class='InputfieldText Inputfield_lblProducts ui-widget' id='wrap_Inputfield_lblProducts'>
<div class='ui-widget-content'>
<p>
<?php
echo '<select id="Inputfield_lblProducts" name="lblProducts[]" multiple="multiple">';
echo "<option value='no product selected'>Select your product</option>";
$products = $pages->get("/products/")->children();
foreach($products as $product) {
echo "<option value='{$product->title}'>{$product->title}</option>";
if ($product->numChildren && $product->rootParent->path == '/products/') {
foreach($product->children as $subsubchild){
echo "<option value='{$subsubchild->title}'>{$subsubchild->title}</option>";
}
}
}
echo "</select> ";
?>
</p>
</div>
</li>
<li class='InputfieldSubmit Inputfield_upload ui-widget' id='wrap_Inputfield_upload'>
<div class='ui-widget-content'>
<button id="Inputfield_upload" class="ui-button ui-widget ui-state-default ui-corner-all" name="upload_submit" value="Upload" type="submit"><span class='ui-button-text'>Send</span></button>
</div>
</li>
</ul>
</form>
<?php } ?>
</div>
</div>
<?php
}
} else {
?>
<form action='./' method='post' class="login_form">
<ul class='Inputfields'>
<li class='InputfieldText Inputfield_lblUsername ui-widget' id='wrap_Inputfield_lblUsername'>
<label class='ui-widget-header' for='Inputfield_lblUsername'>Username</label>
<div class='ui-widget-content'>
<p><input id="Inputfield_lblUsername" class="required InputfieldMaxWidth" name="lblUsername" type="text" maxlength="255" /></p>
</div>
</li>
<li class='InputfieldText Inputfield_lblPassword ui-widget' id='wrap_Inputfield_lblPassword'>
<label class='ui-widget-header' for='Inputfield_lblPassword'>Password</label>
<div class='ui-widget-content'>
<p><input id="Inputfield_lblPassword" class="required InputfieldMaxWidth" name="lblPassword" type="password" maxlength="255" /></p>
</div>
</li>
<li class='InputfieldSubmit Inputfield_login ui-widget' id='wrap_Inputfield_login'>
<label class='ui-widget-header' for='Inputfield_login'>Login</label>
<div class='ui-widget-content'>
<button id="Inputfield_login" class="ui-button ui-widget ui-state-default ui-corner-all" name="login_submit" value="Login" type="submit"><span class='ui-button-text'>Login</span></button>
</div>
</li>
</ul>
</form>
<?php } ?>
- the other one is a logout template which does a simple 301 redirect:
if($user->isLoggedin())
$session->logout();
if ($page->redirect_page)
$session->redirect($page->redirect_page->url);
I also created a new role, added a user.