Ejemplo n.º 1
0
function section_admin_ml_add()
{
    global $tpl, $srcdir, $pdo;
    include $srcdir . '/libs/GoogleApi.php';
    $api = new GoogleApi();
    $mdl = new Modele('sections');
    $mdl->fetch($_REQUEST['section']);
    $mdl->assignTemplate('section');
    $lnk = new Modele('section_ml');
    $lnk->find(array('sm_section' => $_REQUEST['section'], 'sm_ml' => $_REQUEST['ml']));
    if (!$lnk->next()) {
        modexec('syscore', 'forbidden');
    }
    $api->addGroupMember($lnk->sm_ml, $_REQUEST['email']);
    redirect("section", "admin_ml", array("hsuccess" => 1, "section" => $_REQUEST['section'], "ml" => $lnk->sm_ml));
}
Ejemplo n.º 2
0
function user_addGroup()
{
    global $srcdir;
    $usr = new Modele('users');
    $usr->fetch($_GET['user']);
    require_once $srcdir . '/libs/GoogleApi.php';
    $api = new GoogleApi();
    $ret = $api->addGroupMember($_POST['group'], $usr->user_email);
    redirect("user", "view", array('user' => $usr->user_id, 'hsuccess' => isset($ret->error) ? 0 : 1));
}
Ejemplo n.º 3
0
function ml_execUpdate()
{
    $section = new Modele('sections');
    $section->find('section_ml != ""');
    $api = new GoogleApi();
    while ($section->next()) {
        $toAdd = array();
        $toDelete = array();
        $Lmembers = new Modele('user_sections');
        $Lmembers->find(array('us_section' => $section->getKey(), 'us_type' => 'manager'));
        while ($Lmembers->next()) {
            $toAdd[] = strtolower($Lmembers->us_user->user_email);
        }
        $reelMembers = $api->getGroupMembers($section->section_ml);
        if (isset($reelMembers->members)) {
            foreach ($reelMembers->members as $member) {
                $key = array_keys($toAdd, strtolower($member->email));
                if (strpos($member->email, 'save_') !== 0) {
                    //Skip sauvegarde
                    if ($member->type == "GROUP") {
                        continue;
                    } elseif (count($key) == 0) {
                        $toDelete[] = strtolower($member->email);
                    } else {
                        unset($toAdd[$key[0]]);
                    }
                }
            }
        }
        foreach ($toAdd as $mail) {
            $api->addGroupMember($section->section_ml, $mail);
        }
        foreach ($toDelete as $mail) {
            $api->delGroupMember($section->section_ml, $mail);
        }
    }
    redirect('ml', 'autoUpdate');
}