Пример #1
0
 function download($id)
 {
     $media = new Academic($id);
     $media->counter();
     $this->load->helper('download');
     $data = file_get_contents("uploads/academics/" . basename($media->file));
     $name = basename($media->file);
     force_download($name, $data);
 }
Пример #2
0
 function delete($id = FALSE)
 {
     if ($id) {
         $academic = new Academic($id);
         $academic->delete();
         set_notify('success', lang('delete_data_complete'));
     }
     redirect($_SERVER['HTTP_REFERER']);
 }
Пример #3
0
 public function addAcademic(Academic $l)
 {
     $this->collAcademics[] = $l;
     $l->setUser($this);
 }
Пример #4
0
    public function executeManagenewuser()
    {
        $ids = $this->getRequestParameter('ids');
        $action = $this->getRequestParameter('action1');
        $value = 5;
        if ($action == 'approve') {
            $value = 0;
        } elseif ($action == 'reject') {
            $value = 1;
        }
        $idlist = split(',', $ids);
        $count = 0;
        foreach ($idlist as $id) {
            $user = UserPeer::retrieveByPK($id);
            $previslocked = 5;
            if ($user) {
                $previslocked = $user->getIslocked();
                $c = new Criteria();
                $c->add(PersonalPeer::USER_ID, $user->getId());
                $personal = PersonalPeer::doSelectOne($c);
                $name = $personal->getFirstname() . " " . $personal->getMiddlename() . " " . $personal->getLastname();
                $newmail = $personal->getEmail();
                $newpassword = $this->generatePassword();
                $user->setIslocked($value);
                $user->setPassword($newpassword);
                $count++;
                $sendermail = sfConfig::get('app_from_mail');
                $sendername = sfConfig::get('app_from_name');
                $to = $newmail;
                $subject = "Registration request for ITBHU Global Org";
                if ($action == 'approve') {
                    $userrole = new Userrole();
                    $userrole->setRoleId(sfConfig::get('app_role_user'));
                    $userrole->setUserId($id);
                    $userrole->save();
                    $academic = new Academic();
                    $academic->setDegree($user->getDegree()->getName());
                    $academic->setDegreeflag($user->getDegreeflag());
                    $academic->setYear($user->getGraduationyear());
                    $academic->setYearflag($user->getGraduationyearflag());
                    $academic->setDepartment($user->getBranchname());
                    $academic->setDepartmentflag($user->getBranchflag());
                    $academic->setUserId($id);
                    $academic->save();
                    $c->clear();
                    $c->add(ClaiminfoPeer::USER_ID, $id);
                    $claiminfo = ClaiminfoPeer::doSelectOne($c);
                    $user->setUsername($claiminfo->getDusername());
                    $user->save();
                    $body = '
Dear ' . $name . ',

Congrats!! You are now connected to ITBHU GLOBAL.

Your Login Details are:

Username: '******'
Password: '******'

Admin,
ITBHU Global
';
                    //check if there is any authorizer for the batch..
                    $ca = new Criteria();
                    $ca->add(UserPeer::BRANCH_ID, $user->getBranchId());
                    $ca->add(UserPeer::GRADUATIONYEAR, $user->getGraduationyear());
                    $ca->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                    $ca->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_auth'));
                    $authuser = UserPeer::doSelectOne($ca);
                    if (!$authuser) {
                        $body1 = '
Dear ' . $name . ',

Currently there are no authorizers for your batch.

You are invited for the role of Authorizer for your batch.
To accept/reject the invitation, login to http://itbhuglobal.org
and go to settings->invitations.

On accepting the role, you\'ll recieve approval requests from y-
our batchmates.

Admin,
ITBHU Global
';
                    }
                } elseif ($action == 'reject') {
                    if ($previslocked == 2) {
                        $user->setIslocked('1');
                        $user->save();
                    } else {
                        $user->delete();
                        $personal->delete();
                    }
                    $body = '
Dear ' . $name . ',

Your connect request to ITBHU GLOBAL is not approved as your details couldn\'t be verified. 	


Admin,
ITBHU Global
';
                }
                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body);
                if ($body1) {
                    $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body1);
                    $body1 = '';
                    $user->setIsinvited('4');
                    $user->save();
                }
            }
        }
        if ($action == 'approve') {
            if ($count == 0) {
                $this->setFlash('newuseraction', 'No user(s) selected to approve');
            } else {
                $this->setFlash('newuseraction', 'You have successfuly approved ' . $count . ' users');
            }
        } elseif ($action == 'reject') {
            if ($count == 0) {
                $this->setFlash('newuseraction', 'No user(s) selected to reject');
            } else {
                $this->setFlash('newuseraction', 'You have successfuly rejected ' . $count . ' users');
            }
        }
        if ($this->getRequestParameter('from') == 'new') {
            return $this->redirect('auth/newregister');
        } else {
            return $this->redirect('auth/pendinglist');
        }
    }