summaryrefslogblamecommitdiffstats
path: root/app/model/datamods.php
blob: 8eaff23d11a37c748b34dc60980a3ae2543836f6 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                                         

                                     
                                     
                                   
                                     














                                                             





















                                                                                                             




                                              

 
  
<?php

/*
 * SCROTT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * For more information, please refer to UNLICENSE
 */

require_once "class/form.class.php";
require_once "class/agent.class.php";
require_once "class/user.class.php";
require_once "class/group.class.php";
require_once "class/pad.class.php";
require_once "class/stage.class.php";

/*
 * Action: dm-group-add - New group modal
 */
if (isAction("dm-group-add"))
{
    $form = new form();
    $form->text("name");

    if (!$form->populate(input()))
        return;

    $group = group::initNew($form->name, user::getCurrent());
}

/*
 * Action: dm-pad-add - New pad modal
 */
if (isAction("dm-pad-add"))
{
    $form = new form();
    $form->text("owner");
    $form->text("name");

    if (!$form->populate(input()))
        return;

    $owner = agent::getAgentObj($form->owner);
    $user = user::getCurrent();

    if (!$user->canCreateSub($owner))
    {
        logError(ERROR, "You do not have permission to create a pad for '" . $owner->getDisplayName() . "'");
        return;
    }

    $pad = pad::initNew($form->name, $owner);
    $td = stage::initNew("To Do", $pad);
    $ip = stage::initNew("In Progress", $pad);

    $pad->insertStage($td);
    $td->insertStage($ip);
}

?>